From ce4ed265d219f10a8d0485757cc69a97e71a4fb9 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 16 Nov 2012 14:25:03 +0530 Subject: [PATCH] fixes to rename_tool, added serial no for rename --- home/page/latest_updates/latest_updates.js | 1 + selling/doctype/lead/lead_list.js | 2 +- stock/doctype/serial_no/serial_no.py | 21 ++++++-- utilities/doctype/rename_tool/rename_tool.py | 5 -- utilities/doctype/rename_tool/rename_tool.txt | 49 ++++++++++--------- 5 files changed, 45 insertions(+), 33 deletions(-) diff --git a/home/page/latest_updates/latest_updates.js b/home/page/latest_updates/latest_updates.js index 2f52e7f56b..35cc2f7830 100644 --- a/home/page/latest_updates/latest_updates.js +++ b/home/page/latest_updates/latest_updates.js @@ -4,6 +4,7 @@ erpnext.updates = [ the appraiser can select the template and role and make an appraisal. \ Normal user can see self created Appraisals. HR Manager can see all Appraisals.", "Project: Bugfix in Gantt Chart (caused due to jquery conflict)", + "Serial No: Ability to rename.", ]], ["15th November 2012", [ "Customer Issue: Moved all allocations to 'Assigned' so that there is avoid duplication fo features.", diff --git a/selling/doctype/lead/lead_list.js b/selling/doctype/lead/lead_list.js index e3ff931366..e700bc89a1 100644 --- a/selling/doctype/lead/lead_list.js +++ b/selling/doctype/lead/lead_list.js @@ -19,7 +19,7 @@ wn.doclistviews['Lead'] = wn.views.ListView.extend({ data.label_type = 'info' } data.status_html = repl('%(status)s', data); - data.lead_name = repl("%(lead_name)s", + data.lead_name = repl("%(name): %(lead_name)s", data); data.lead_status = (data.rating ? ('['+data.rating+'] ') : '') + '['+data.source+']'; }, diff --git a/stock/doctype/serial_no/serial_no.py b/stock/doctype/serial_no/serial_no.py index 931e0fe480..63b23ca902 100644 --- a/stock/doctype/serial_no/serial_no.py +++ b/stock/doctype/serial_no/serial_no.py @@ -118,8 +118,23 @@ class DocType(TransactionBase): def on_cancel(self): self.on_trash() - # ----------- - # on restore - # ----------- def on_restore(self): self.make_stock_ledger_entry(1) + + def on_rename(self, new, old): + """rename serial_no text fields""" + for dt in webnotes.conn.sql("""select parent from tabDocField + where fieldname='serial_no' and fieldtype='Text'"""): + + for item in webnotes.conn.sql("""select name, serial_no from `tab%s` + where serial_no like '%%%s%%'""" % (dt[0], old)): + + serial_nos = map(lambda i: i==old and new or i, item[1].split('\n')) + webnotes.conn.sql("""update `tab%s` set serial_no = %s + where name=%s""" % (dt[0], '%s', '%s'), + ('\n'.join(serial_nos), item[0])) + + + + + \ No newline at end of file diff --git a/utilities/doctype/rename_tool/rename_tool.py b/utilities/doctype/rename_tool/rename_tool.py index 2a2ad92edb..b0d76719d2 100644 --- a/utilities/doctype/rename_tool/rename_tool.py +++ b/utilities/doctype/rename_tool/rename_tool.py @@ -25,11 +25,6 @@ class DocType: """ import webnotes.model from webnotes.model.code import get_obj - - # call on_rename method if exists - obj = get_obj(self.doc.select_doctype, self.doc.document_to_rename) - if hasattr(obj, 'on_rename'): - obj.on_rename(self.doc.new_name,self.doc.document_to_rename) # rename the document webnotes.model.rename(self.doc.select_doctype, self.doc.document_to_rename, self.doc.new_name) diff --git a/utilities/doctype/rename_tool/rename_tool.txt b/utilities/doctype/rename_tool/rename_tool.txt index c9ee46fb8b..e7a08ecc2a 100755 --- a/utilities/doctype/rename_tool/rename_tool.txt +++ b/utilities/doctype/rename_tool/rename_tool.txt @@ -3,11 +3,11 @@ # These values are common in all dictionaries { - 'creation': '2012-05-03 18:43:31', - 'docstatus': 0, - 'modified': '2012-05-25 11:58:44', - 'modified_by': u'Administrator', - 'owner': u'Administrator' + u'creation': '2012-07-03 13:30:42', + u'docstatus': 0, + u'modified': '2012-11-16 14:16:09', + u'modified_by': u'Administrator', + u'owner': u'Administrator' }, # These values are common for all DocType @@ -16,12 +16,12 @@ 'allow_email': 1, 'allow_print': 1, 'colour': u'White:FFF', - 'doctype': 'DocType', + u'doctype': u'DocType', 'hide_heading': 0, 'hide_toolbar': 0, 'issingle': 1, 'module': u'Utilities', - 'name': '__common__', + u'name': u'__common__', 'section_style': u'Simple', 'show_in_menu': 0, 'version': 1 @@ -29,8 +29,8 @@ # These values are common for all DocField { - 'doctype': u'DocField', - 'name': '__common__', + u'doctype': u'DocField', + u'name': u'__common__', 'parent': u'Rename Tool', 'parentfield': u'fields', 'parenttype': u'DocType', @@ -40,8 +40,8 @@ # These values are common for all DocPerm { 'create': 1, - 'doctype': u'DocPerm', - 'name': '__common__', + u'doctype': u'DocPerm', + u'name': u'__common__', 'parent': u'Rename Tool', 'parentfield': u'permissions', 'parenttype': u'DocType', @@ -53,35 +53,31 @@ # DocType, Rename Tool { - 'doctype': 'DocType', - 'name': u'Rename Tool' - }, - - # DocPerm - { - 'doctype': u'DocPerm' + u'doctype': u'DocType', + u'name': u'Rename Tool' }, # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'select_doctype', 'fieldtype': u'Select', 'label': u'Select DocType', - 'options': u'\nAccount\nCompany\nCustomer\nSupplier\nEmployee\nWarehouse\nItem\nProfile' + 'options': u'\nAccount\nCompany\nCustomer\nSupplier\nEmployee\nWarehouse\nItem\nProfile\nSerial No' }, # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'document_to_rename', 'fieldtype': u'Link', - 'label': u'Document to rename' + 'label': u'Document to rename', + 'options': u'[Select]' }, # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'new_name', 'fieldtype': u'Data', 'label': u'New Name' @@ -89,10 +85,15 @@ # DocField { - 'doctype': u'DocField', + u'doctype': u'DocField', 'fieldname': u'rename', 'fieldtype': u'Button', 'label': u'Rename', 'options': u'rename' + }, + + # DocPerm + { + u'doctype': u'DocPerm' } ] \ No newline at end of file