Merge pull request #12464 from Zlash65/fix-company-bom-deletion

[Fix] Delete BOM only when found
This commit is contained in:
Saurabh 2018-01-12 16:47:54 +05:30 committed by GitHub
commit 93d3020e4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -283,10 +283,11 @@ class Company(Document):
# 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))
if boms:
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), debug=1)
@frappe.whitelist()
def enqueue_replace_abbr(company, old, new):