lock old row before rename
This commit is contained in:
parent
74c21db40f
commit
74b335ce29
1 changed files with 3 additions and 1 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue