bulk rename py
This commit is contained in:
parent
8cfa84a646
commit
f96fa9a87b
@ -39,7 +39,6 @@ class DocType:
|
|||||||
webnotes.conn.begin()
|
webnotes.conn.begin()
|
||||||
webnotes.model.rename(self.doc.rename_doctype, rec[0]['name'], new_name)
|
webnotes.model.rename(self.doc.rename_doctype, rec[0]['name'], new_name)
|
||||||
sql("update `tabAccount` set account_name = '%s' where name = '%s'" %(line[1],new_name))
|
sql("update `tabAccount` set account_name = '%s' where name = '%s'" %(line[1],new_name))
|
||||||
msgprint(new_name)
|
|
||||||
webnotes.conn.commit()
|
webnotes.conn.commit()
|
||||||
|
|
||||||
updated += 1
|
updated += 1
|
||||||
@ -49,16 +48,15 @@ class DocType:
|
|||||||
for line in data:
|
for line in data:
|
||||||
if len(line)==2:
|
if len(line)==2:
|
||||||
|
|
||||||
# call on_rename method if exists
|
webnotes.conn.begin()
|
||||||
|
|
||||||
obj = get_obj(self.doc.rename_doctype, line[0])
|
obj = get_obj(self.doc.rename_doctype, line[0])
|
||||||
if hasattr(obj, 'on_rename'):
|
if hasattr(obj, 'on_rename'):
|
||||||
obj.on_rename(line[1],line[0])
|
obj.on_rename(line[1],line[0])
|
||||||
|
|
||||||
# rename the document
|
|
||||||
webnotes.model.rename(self.doc.rename_doctype, line[0], line[1])
|
webnotes.model.rename(self.doc.rename_doctype, line[0], line[1])
|
||||||
|
|
||||||
sql("commit")
|
webnotes.conn.commit()
|
||||||
sql("start transaction")
|
|
||||||
|
|
||||||
updated += 1
|
updated += 1
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user