From 9990306399b6bd8eaa9aad7446edb4d8515def31 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 25 Feb 2019 11:59:05 +0530 Subject: [PATCH] fix: Consider only active BOMs while updating cost via BOM Update Tool (#16753) --- erpnext/manufacturing/doctype/bom/bom.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index 88d346ff0f..ea6b7ede92 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -706,8 +706,11 @@ def get_children(doctype, parent=None, is_root=False, **filters): def get_boms_in_bottom_up_order(bom_no=None): def _get_parent(bom_no): - return frappe.db.sql_list("""select distinct parent from `tabBOM Item` - where bom_no = %s and docstatus=1 and parenttype='BOM'""", bom_no) + return frappe.db.sql_list(""" + select distinct bom_item.parent from `tabBOM Item` bom_item + where bom_item.bom_no = %s and bom_item.docstatus=1 and bom_item.parenttype='BOM' + and exists(select bom.name from `tabBOM` bom where bom.name=bom_item.parent and bom.is_active=1) + """, bom_no) count = 0 bom_list = [] @@ -715,9 +718,10 @@ def get_boms_in_bottom_up_order(bom_no=None): bom_list.append(bom_no) else: # get all leaf BOMs - bom_list = frappe.db.sql_list("""select name from `tabBOM` bom where docstatus=1 - and not exists(select bom_no from `tabBOM Item` - where parent=bom.name and ifnull(bom_no, '')!='')""") + bom_list = frappe.db.sql_list("""select name from `tabBOM` bom + where docstatus=1 and is_active=1 + and not exists(select bom_no from `tabBOM Item` + where parent=bom.name and ifnull(bom_no, '')!='')""") while(count < len(bom_list)): for child_bom in _get_parent(bom_list[count]):