fix: Consider only active BOMs while updating cost via BOM Update Tool (#16753)

This commit is contained in:
Nabin Hait 2019-02-25 11:59:05 +05:30 committed by Sagar Vora
parent e2de8e0fa5
commit 9990306399

View File

@ -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]):