|
|
@@ -89,12 +89,16 @@ def rename_parent_and_child(doctype, old, new, meta): |
|
|
|
|
|
|
|
def validate_rename(doctype, new, meta, merge, force, ignore_permissions): |
|
|
|
# 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 COLLATE utf8mb4_unicode_ci for update".format(doctype=frappe.db.escape(doctype)), new) |
|
|
|
exists = frappe.db.sql("select name from `tab{doctype}` where name=%s for update".format(doctype=frappe.db.escape(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) |
|
|
|
|
|
|
|
if exists and exists != new: |
|
|
|
# for fixing case, accents |
|
|
|
exists = None |
|
|
|
|
|
|
|
if (not merge) and exists: |
|
|
|
frappe.msgprint(_("Another {0} with name {1} exists, select another name").format(doctype, new), raise_exception=1) |
|
|
|
|
|
|
|