fix: incorrect qty calculation in the production plan fopr the sub assembely work orders (#18970)
This commit is contained in:
parent
e919388ee6
commit
bb736248a2
@ -716,6 +716,8 @@ def get_children(doctype, parent=None, is_root=False, **filters):
|
|||||||
next(item for item in items if item.get('name')
|
next(item for item in items if item.get('name')
|
||||||
== bom_item.get('item_code'))
|
== 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
|
bom_item.expandable = 0 if bom_item.value in ('', None) else 1
|
||||||
|
|
||||||
return bom_items
|
return bom_items
|
||||||
|
@ -301,7 +301,6 @@ class ProductionPlan(Document):
|
|||||||
wo_list.extend(work_orders)
|
wo_list.extend(work_orders)
|
||||||
|
|
||||||
frappe.flags.mute_messages = False
|
frappe.flags.mute_messages = False
|
||||||
|
|
||||||
if wo_list:
|
if wo_list:
|
||||||
wo_list = ["""<a href="#Form/Work Order/%s" target="_blank">%s</a>""" % \
|
wo_list = ["""<a href="#Form/Work Order/%s" target="_blank">%s</a>""" % \
|
||||||
(p, p) for p in wo_list]
|
(p, p) for p in wo_list]
|
||||||
@ -309,15 +308,16 @@ class ProductionPlan(Document):
|
|||||||
else :
|
else :
|
||||||
msgprint(_("No Work Orders created"))
|
msgprint(_("No Work Orders created"))
|
||||||
|
|
||||||
|
|
||||||
def make_work_order_for_sub_assembly_items(self, item):
|
def make_work_order_for_sub_assembly_items(self, item):
|
||||||
work_orders = []
|
work_orders = []
|
||||||
bom_data = {}
|
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():
|
for key, data in bom_data.items():
|
||||||
data.update({
|
data.update({
|
||||||
'qty': data.get("stock_qty") * item.get("qty"),
|
'qty': data.get("stock_qty"),
|
||||||
'production_plan': self.name,
|
'production_plan': self.name,
|
||||||
'company': self.company,
|
'company': self.company,
|
||||||
'fg_warehouse': item.get("fg_warehouse"),
|
'fg_warehouse': item.get("fg_warehouse"),
|
||||||
@ -708,7 +708,7 @@ def get_item_data(item_code):
|
|||||||
"description": item_details.get("description")
|
"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)
|
data = get_children('BOM', parent = bom_no)
|
||||||
for d in data:
|
for d in data:
|
||||||
if d.expandable:
|
if d.expandable:
|
||||||
@ -725,6 +725,6 @@ def get_sub_assembly_items(bom_no, bom_data):
|
|||||||
})
|
})
|
||||||
|
|
||||||
bom_item = bom_data.get(key)
|
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"])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user