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. \
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.",

View File

@ -19,7 +19,7 @@ wn.doclistviews['Lead'] = wn.views.ListView.extend({
data.label_type = 'info'
}
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.lead_status = (data.rating ? ('['+data.rating+'] ') : '') + '['+data.source+']';
},

View File

@ -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]))

View File

@ -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)

View File

@ -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'
}
]