ソースを参照

[fix] check against all linked documents while canceling or deleting (#2360)

version-14
Saurabh 8年前
committed by Rushabh Mehta
コミット
d40d08fb66
1個のファイルの変更10行の追加10行の削除
  1. +10
    -10
      frappe/model/delete_doc.py

+ 10
- 10
frappe/model/delete_doc.py ファイルの表示

@@ -168,16 +168,16 @@ def check_if_doc_is_linked(doc, method="Delete"):

for link_dt, link_field, issingle in link_fields:
if not issingle:
item = frappe.db.get_value(link_dt, {link_field:doc.name},
["name", "parent", "parenttype", "docstatus"], as_dict=True)
if item and ((item.parent or item.name) != doc.name) \
and ((method=="Delete" and item.docstatus<2) or (method=="Cancel" and item.docstatus==1)):
# raise exception only if
# linked to an non-cancelled doc when deleting
# or linked to a submitted doc when cancelling
frappe.throw(_("Cannot delete or cancel because {0} {1} is linked with {2} {3}")
.format(doc.doctype, doc.name, item.parenttype if item.parent else link_dt,
item.parent or item.name), frappe.LinkExistsError)
for item in frappe.db.get_values(link_dt, {link_field:doc.name},
["name", "parent", "parenttype", "docstatus"], as_dict=True):
if item and ((item.parent or item.name) != doc.name) \
and ((method=="Delete" and item.docstatus<2) or (method=="Cancel" and item.docstatus==1)):
# raise exception only if
# linked to an non-cancelled doc when deleting
# or linked to a submitted doc when cancelling
frappe.throw(_("Cannot delete or cancel because {0} {1} is linked with {2} {3}")
.format(doc.doctype, doc.name, item.parenttype if item.parent else link_dt,
item.parent or item.name), frappe.LinkExistsError)

def check_if_doc_is_dynamically_linked(doc, method="Delete"):
'''Raise `frappe.LinkExistsError` if the document is dynamically linked'''


読み込み中…
キャンセル
保存