Serial No Rename
This commit is contained in:
parent
1117125841
commit
949fbc559e
@ -159,13 +159,19 @@ class SerialNo(StockController):
|
|||||||
|
|
||||||
def after_rename(self, old, new, merge=False):
|
def after_rename(self, old, new, merge=False):
|
||||||
"""rename serial_no text fields"""
|
"""rename serial_no text fields"""
|
||||||
|
print "--------------------RENAME SERIAL NO-------------------------------"
|
||||||
|
print old
|
||||||
|
print new
|
||||||
for dt in frappe.db.sql("""select parent from tabDocField
|
for dt in frappe.db.sql("""select parent from tabDocField
|
||||||
where fieldname='serial_no' and fieldtype='Text'"""):
|
where fieldname='serial_no' and fieldtype='Text'"""):
|
||||||
|
print "--------------GOT PARENTS-------------------"
|
||||||
for item in frappe.db.sql("""select name, serial_no from `tab%s`
|
for item in frappe.db.sql("""select name, serial_no from `tab%s`
|
||||||
where serial_no like '%%%s%%'""" % (dt[0], frappe.db.escape(old))):
|
where serial_no like '%%%s%%'""" % (dt[0], frappe.db.escape(old))):
|
||||||
|
|
||||||
serial_nos = map(lambda i: i==old and new or i, item[1].split('\n'))
|
serial_nos = map(lambda i: new if i.upper()==old.upper() else i, item[1].split('\n'))
|
||||||
|
print "----------------------IN SERIAL NO-------------------------------"
|
||||||
|
print serial_nos
|
||||||
|
print "-----------------------------------------------------------------"
|
||||||
frappe.db.sql("""update `tab%s` set serial_no = %s
|
frappe.db.sql("""update `tab%s` set serial_no = %s
|
||||||
where name=%s""" % (dt[0], '%s', '%s'),
|
where name=%s""" % (dt[0], '%s', '%s'),
|
||||||
('\n'.join(serial_nos), item[0]))
|
('\n'.join(serial_nos), item[0]))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user