lock old row before rename

This commit is contained in:
Anand Doshi 2015-02-27 14:32:01 +05:30
parent 74c21db40f
commit 74b335ce29

View file

@ -82,7 +82,9 @@ def rename_parent_and_child(doctype, old, new, meta):
update_child_docs(old, new, meta)
def validate_rename(doctype, new, meta, merge, force, ignore_permissions):
exists = frappe.db.get_value(doctype, new)
# using for update so that it gets locked and someone else cannot edit it while this rename is going on!
exists = frappe.db.sql("select name from `tab{doctype}` where name=%s for update".format(doctype=doctype), new)
exists = exists[0][0] if exists else None
if merge and not exists:
frappe.msgprint(_("{0} {1} does not exist, select a new target to merge").format(doctype, new), raise_exception=1)