From 4987c4ef53dd6fd71c89d790c7e83e48b707905a Mon Sep 17 00:00:00 2001 From: Shridhar Patil Date: Tue, 3 Jul 2018 10:10:04 +0530 Subject: [PATCH] on delete contact update issue (#14770) * on delete contact update isuue remove contact from issue if the deleted contact exists * moved issue update function to issue.py * Update formatting and comment --- erpnext/hooks.py | 3 +++ erpnext/support/doctype/issue/issue.py | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/erpnext/hooks.py b/erpnext/hooks.py index b461e166f9..8d09f29b34 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -210,6 +210,9 @@ doc_events = { }, ('Sales Invoice', 'Purchase Invoice', 'Delivery Note'): { 'validate': 'erpnext.regional.india.utils.set_place_of_supply' + }, + "Contact":{ + "on_trash": "erpnext.support.doctype.issue.issue.update_issue" } } diff --git a/erpnext/support/doctype/issue/issue.py b/erpnext/support/doctype/issue/issue.py index dfcc2a8936..ef54b20efc 100644 --- a/erpnext/support/doctype/issue/issue.py +++ b/erpnext/support/doctype/issue/issue.py @@ -130,3 +130,8 @@ def set_multiple_status(names, status): def has_website_permission(doc, ptype, user, verbose=False): return doc.raised_by==user + + +def update_issue(contact, method): + """Called when Contact is deleted""" + frappe.db.sql("""UPDATE `tabIssue` set contact='' where contact=%s""", contact.name)