From f96fa9a87b512e4e96b4cf5ca722add353d423aa Mon Sep 17 00:00:00 2001 From: Ravi Dey Date: Thu, 7 Jul 2011 16:43:56 +0530 Subject: [PATCH] bulk rename py --- .../doctype/bulk_rename_tool/bulk_rename_tool.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/utilities/doctype/bulk_rename_tool/bulk_rename_tool.py b/utilities/doctype/bulk_rename_tool/bulk_rename_tool.py index b8818f4407..19cf07f6c1 100644 --- a/utilities/doctype/bulk_rename_tool/bulk_rename_tool.py +++ b/utilities/doctype/bulk_rename_tool/bulk_rename_tool.py @@ -38,8 +38,7 @@ class DocType: webnotes.conn.begin() 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)) - msgprint(new_name) + sql("update `tabAccount` set account_name = '%s' where name = '%s'" %(line[1],new_name)) webnotes.conn.commit() updated += 1 @@ -49,16 +48,15 @@ class DocType: for line in data: if len(line)==2: - # call on_rename method if exists + webnotes.conn.begin() + obj = get_obj(self.doc.rename_doctype, line[0]) if hasattr(obj, 'on_rename'): - obj.on_rename(line[1],line[0]) - - # rename the document + obj.on_rename(line[1],line[0]) + webnotes.model.rename(self.doc.rename_doctype, line[0], line[1]) - sql("commit") - sql("start transaction") + webnotes.conn.commit() updated += 1 else: