Delete BOMs on deletion of company

This commit is contained in:
Nabin Hait 2018-01-09 16:29:13 +05:30
parent 6b89644ca7
commit 527e6c02b3

View File

@ -281,6 +281,12 @@ class Company(Document):
# delete mode of payment account
frappe.db.sql("delete from `tabMode of Payment Account` where company=%s", self.name)
# delete BOMs
boms = frappe.db.sql_list("select name from tabBOM where company=%s", self.name)
frappe.db.sql("delete from tabBOM where company=%s", self.name)
for dt in ("BOM Operation", "BOM Item", "BOM Scrap Item", "BOM Explosion Item"):
frappe.db.sql("delete from `tab%s` where parent in (%s)"""
% (dt, ', '.join(['%s']*len(boms))), tuple(boms))
@frappe.whitelist()
def enqueue_replace_abbr(company, old, new):