|
|
@@ -270,7 +270,7 @@ def delete(doctype, name): |
|
|
|
|
|
|
|
:param doctype: DocType of the document to be deleted |
|
|
|
:param name: name of the document to be deleted""" |
|
|
|
frappe.delete_doc(doctype, name, ignore_missing=False) |
|
|
|
delete_doc(doctype, name) |
|
|
|
|
|
|
|
|
|
|
|
@frappe.whitelist(methods=["POST", "PUT"]) |
|
|
@@ -462,3 +462,23 @@ def insert_doc(doc) -> "Document": |
|
|
|
return parent |
|
|
|
|
|
|
|
return frappe.get_doc(doc).insert() |
|
|
|
|
|
|
|
|
|
|
|
def delete_doc(doctype, name): |
|
|
|
"""Deletes document |
|
|
|
if doctype is a child table, then deletes the child record using the parent doc |
|
|
|
so that the parent doc's `on_update` is called |
|
|
|
""" |
|
|
|
|
|
|
|
if frappe.is_table(doctype): |
|
|
|
parenttype, parent, parentfield = frappe.db.get_value( |
|
|
|
doctype, name, ["parenttype", "parent", "parentfield"] |
|
|
|
) |
|
|
|
parent = frappe.get_doc(parenttype, parent) |
|
|
|
for row in parent.get(parentfield): |
|
|
|
if row.name == name: |
|
|
|
parent.remove(row) |
|
|
|
parent.save() |
|
|
|
break |
|
|
|
else: |
|
|
|
frappe.delete_doc(doctype, name, ignore_missing=False) |