Merge pull request #13694 from deepeshgarg007/api_update
fix: Error on updating docs via API
This commit is contained in:
commit
4d38093f6c
2 changed files with 4 additions and 4 deletions
|
|
@ -82,7 +82,7 @@ def handle():
|
|||
if frappe.local.request.method=="PUT":
|
||||
data = get_request_form_data()
|
||||
|
||||
doc = frappe.get_doc(doctype, name)
|
||||
doc = frappe.get_doc(doctype, name, for_update=True)
|
||||
|
||||
if "flags" in data:
|
||||
del data["flags"]
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ def update_add_node(doc, parent, parent_field):
|
|||
|
||||
# get the last sibling of the parent
|
||||
if parent:
|
||||
left, right = frappe.db.sql("select lft, rgt from `tab{0}` where name=%s"
|
||||
left, right = frappe.db.sql("select lft, rgt from `tab{0}` where name=%s for update"
|
||||
.format(doctype), parent)[0]
|
||||
validate_loop(doc.doctype, doc.name, left, right)
|
||||
else: # root
|
||||
|
|
@ -89,7 +89,7 @@ def update_move_node(doc, parent_field):
|
|||
|
||||
if parent:
|
||||
new_parent = frappe.db.sql("""select lft, rgt from `tab{0}`
|
||||
where name = %s""".format(doc.doctype), parent, as_dict=1)[0]
|
||||
where name = %s for update""".format(doc.doctype), parent, as_dict=1)[0]
|
||||
|
||||
validate_loop(doc.doctype, doc.name, new_parent.lft, new_parent.rgt)
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ def update_move_node(doc, parent_field):
|
|||
|
||||
if parent:
|
||||
new_parent = frappe.db.sql("""select lft, rgt from `tab%s`
|
||||
where name = %s""" % (doc.doctype, '%s'), parent, as_dict=1)[0]
|
||||
where name = %s for update""" % (doc.doctype, '%s'), parent, as_dict=1)[0]
|
||||
|
||||
|
||||
# set parent lft, rgt
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue