fixes to rename_tool, added serial no for rename

This commit is contained in:
Rushabh Mehta 2012-11-16 14:25:03 +05:30
parent 188185f3a3
commit ce4ed265d2
5 changed files with 45 additions and 33 deletions

View File

@ -4,6 +4,7 @@ erpnext.updates = [
the appraiser can select the template and role and make an appraisal. \ 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.", Normal user can see self created Appraisals. HR Manager can see all Appraisals.",
"Project: Bugfix in Gantt Chart (caused due to jquery conflict)", "Project: Bugfix in Gantt Chart (caused due to jquery conflict)",
"Serial No: Ability to rename.",
]], ]],
["15th November 2012", [ ["15th November 2012", [
"Customer Issue: Moved all allocations to 'Assigned' so that there is avoid duplication fo features.", "Customer Issue: Moved all allocations to 'Assigned' so that there is avoid duplication fo features.",

View File

@ -19,7 +19,7 @@ wn.doclistviews['Lead'] = wn.views.ListView.extend({
data.label_type = 'info' data.label_type = 'info'
} }
data.status_html = repl('<span class="label label-%(label_type)s">%(status)s</span>', data); data.status_html = repl('<span class="label label-%(label_type)s">%(status)s</span>', data);
data.lead_name = repl("<a href=\"#!Form/Lead/%(name)s\">%(lead_name)s</a>", data.lead_name = repl("<a href=\"#!Form/Lead/%(name)s\">%(name): %(lead_name)s</a>",
data); data);
data.lead_status = (data.rating ? ('['+data.rating+'] ') : '') + '['+data.source+']'; data.lead_status = (data.rating ? ('['+data.rating+'] ') : '') + '['+data.source+']';
}, },

View File

@ -118,8 +118,23 @@ class DocType(TransactionBase):
def on_cancel(self): def on_cancel(self):
self.on_trash() self.on_trash()
# -----------
# on restore
# -----------
def on_restore(self): def on_restore(self):
self.make_stock_ledger_entry(1) 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]))

View File

@ -25,11 +25,6 @@ class DocType:
""" """
import webnotes.model import webnotes.model
from webnotes.model.code import get_obj 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 # rename the document
webnotes.model.rename(self.doc.select_doctype, self.doc.document_to_rename, self.doc.new_name) webnotes.model.rename(self.doc.select_doctype, self.doc.document_to_rename, self.doc.new_name)

View File

@ -3,11 +3,11 @@
# These values are common in all dictionaries # These values are common in all dictionaries
{ {
'creation': '2012-05-03 18:43:31', u'creation': '2012-07-03 13:30:42',
'docstatus': 0, u'docstatus': 0,
'modified': '2012-05-25 11:58:44', u'modified': '2012-11-16 14:16:09',
'modified_by': u'Administrator', u'modified_by': u'Administrator',
'owner': u'Administrator' u'owner': u'Administrator'
}, },
# These values are common for all DocType # These values are common for all DocType
@ -16,12 +16,12 @@
'allow_email': 1, 'allow_email': 1,
'allow_print': 1, 'allow_print': 1,
'colour': u'White:FFF', 'colour': u'White:FFF',
'doctype': 'DocType', u'doctype': u'DocType',
'hide_heading': 0, 'hide_heading': 0,
'hide_toolbar': 0, 'hide_toolbar': 0,
'issingle': 1, 'issingle': 1,
'module': u'Utilities', 'module': u'Utilities',
'name': '__common__', u'name': u'__common__',
'section_style': u'Simple', 'section_style': u'Simple',
'show_in_menu': 0, 'show_in_menu': 0,
'version': 1 'version': 1
@ -29,8 +29,8 @@
# These values are common for all DocField # These values are common for all DocField
{ {
'doctype': u'DocField', u'doctype': u'DocField',
'name': '__common__', u'name': u'__common__',
'parent': u'Rename Tool', 'parent': u'Rename Tool',
'parentfield': u'fields', 'parentfield': u'fields',
'parenttype': u'DocType', 'parenttype': u'DocType',
@ -40,8 +40,8 @@
# These values are common for all DocPerm # These values are common for all DocPerm
{ {
'create': 1, 'create': 1,
'doctype': u'DocPerm', u'doctype': u'DocPerm',
'name': '__common__', u'name': u'__common__',
'parent': u'Rename Tool', 'parent': u'Rename Tool',
'parentfield': u'permissions', 'parentfield': u'permissions',
'parenttype': u'DocType', 'parenttype': u'DocType',
@ -53,35 +53,31 @@
# DocType, Rename Tool # DocType, Rename Tool
{ {
'doctype': 'DocType', u'doctype': u'DocType',
'name': u'Rename Tool' u'name': u'Rename Tool'
},
# DocPerm
{
'doctype': u'DocPerm'
}, },
# DocField # DocField
{ {
'doctype': u'DocField', u'doctype': u'DocField',
'fieldname': u'select_doctype', 'fieldname': u'select_doctype',
'fieldtype': u'Select', 'fieldtype': u'Select',
'label': u'Select DocType', '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 # DocField
{ {
'doctype': u'DocField', u'doctype': u'DocField',
'fieldname': u'document_to_rename', 'fieldname': u'document_to_rename',
'fieldtype': u'Link', 'fieldtype': u'Link',
'label': u'Document to rename' 'label': u'Document to rename',
'options': u'[Select]'
}, },
# DocField # DocField
{ {
'doctype': u'DocField', u'doctype': u'DocField',
'fieldname': u'new_name', 'fieldname': u'new_name',
'fieldtype': u'Data', 'fieldtype': u'Data',
'label': u'New Name' 'label': u'New Name'
@ -89,10 +85,15 @@
# DocField # DocField
{ {
'doctype': u'DocField', u'doctype': u'DocField',
'fieldname': u'rename', 'fieldname': u'rename',
'fieldtype': u'Button', 'fieldtype': u'Button',
'label': u'Rename', 'label': u'Rename',
'options': u'rename' 'options': u'rename'
},
# DocPerm
{
u'doctype': u'DocPerm'
} }
] ]