diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py index 22c2f694f53..8eb4c9c28c8 100644 --- a/erpnext/manufacturing/doctype/bom/bom.py +++ b/erpnext/manufacturing/doctype/bom/bom.py @@ -716,6 +716,8 @@ def get_children(doctype, parent=None, is_root=False, **filters): next(item for item in items if item.get('name') == bom_item.get('item_code')) ) + + bom_item.parent_bom_qty = bom_doc.quantity bom_item.expandable = 0 if bom_item.value in ('', None) else 1 return bom_items diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.py b/erpnext/manufacturing/doctype/production_plan/production_plan.py index 048ce0d6ef8..b51420ffdbe 100644 --- a/erpnext/manufacturing/doctype/production_plan/production_plan.py +++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py @@ -301,7 +301,6 @@ class ProductionPlan(Document): wo_list.extend(work_orders) frappe.flags.mute_messages = False - if wo_list: wo_list = ["""%s""" % \ (p, p) for p in wo_list] @@ -309,15 +308,16 @@ class ProductionPlan(Document): else : msgprint(_("No Work Orders created")) + def make_work_order_for_sub_assembly_items(self, item): work_orders = [] bom_data = {} - get_sub_assembly_items(item.get("bom_no"), bom_data) + get_sub_assembly_items(item.get("bom_no"), bom_data, item.get("qty")) for key, data in bom_data.items(): data.update({ - 'qty': data.get("stock_qty") * item.get("qty"), + 'qty': data.get("stock_qty"), 'production_plan': self.name, 'company': self.company, 'fg_warehouse': item.get("fg_warehouse"), @@ -708,7 +708,7 @@ def get_item_data(item_code): "description": item_details.get("description") } -def get_sub_assembly_items(bom_no, bom_data): +def get_sub_assembly_items(bom_no, bom_data, qty): data = get_children('BOM', parent = bom_no) for d in data: if d.expandable: @@ -725,6 +725,6 @@ def get_sub_assembly_items(bom_no, bom_data): }) bom_item = bom_data.get(key) - bom_item["stock_qty"] += d.stock_qty + bom_item["stock_qty"] += ((d.stock_qty * qty) / d.parent_bom_qty) - get_sub_assembly_items(bom_item.get("bom_no"), bom_data) + get_sub_assembly_items(bom_item.get("bom_no"), bom_data, bom_item["stock_qty"])