fix: prevent deletion if document is locked

This commit is contained in:
Ankush Menat 2024-02-29 16:34:14 +05:30
parent e810fb7eca
commit fc5ce044e6

View file

@ -104,7 +104,17 @@ def delete_doc(
pass
else:
doc = frappe.get_doc(doctype, name, for_update=True)
# Lock the doc without waiting
try:
frappe.db.get_value(doctype, name, for_update=True, wait=False)
except frappe.QueryTimeoutError:
frappe.throw(
_(
"This document can not be deleted right now as it's being modified by another user. Please try again after some time."
),
exc=frappe.QueryTimeoutError,
)
doc = frappe.get_doc(doctype, name)
if not for_reload:
update_flags(doc, flags, ignore_permissions)