From 0248811e532e77f0853e0d992ac895f2e45b27e0 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Wed, 15 Jul 2015 15:03:45 +0530 Subject: [PATCH 1/2] Fixed deafault BOM problem --- erpnext/manufacturing/doctype/bom/bom.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index f550a8afe41..fe67ed8057d 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -181,15 +181,12 @@ class BOM(Document): if item.default_bom != self.name: item.default_bom = self.name item.save() - else: - if not self.is_active: - frappe.db.set(self, "is_default", 0) - - item = frappe.get_doc("Item", self.item) - if item.default_bom == self.name: - item.default_bom = None - item.save() + frappe.db.set(self, "is_default", 0) + item = frappe.get_doc("Item", self.item) + if item.default_bom == self.name: + item.default_bom = None + item.save() def clear_operations(self): if not self.with_operations: From 20523c45c76c11b620de54c1ba770d9ef29b5a9a Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Wed, 15 Jul 2015 16:39:05 +0530 Subject: [PATCH 2/2] Patch for default BOM --- erpnext/patches.txt | 1 + erpnext/patches/v5_1/default_bom.py | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 erpnext/patches/v5_1/default_bom.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index f5ae5b718bc..c4836653c8b 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -176,3 +176,4 @@ erpnext.patches.v5_1.track_operations erpnext.patches.v5_1.sales_bom_rename execute:frappe.rename_doc("DocType", "Salary Manager", "Process Payroll", force=True) erpnext.patches.v5_1.rename_roles +erpnext.patches.v5_1.default_bom diff --git a/erpnext/patches/v5_1/default_bom.py b/erpnext/patches/v5_1/default_bom.py new file mode 100644 index 00000000000..6484edd6039 --- /dev/null +++ b/erpnext/patches/v5_1/default_bom.py @@ -0,0 +1,7 @@ +from __future__ import unicode_literals + +import frappe + +def execute(): + frappe.db.sql("""Update `tabItem` as item set default_bom = NULL where + not exists(select name from `tabBOM` as bom where item.default_bom = bom.name and bom.docstatus =1 )""") \ No newline at end of file