fix: wrong operation time in Work Order (#26613)
* fix: wrong operation time in Work Order Top level item time operation was not considering the BOM.quantity Co-authored-by: Ankush Menat <ankush@iwebnotes.com>
This commit is contained in:
parent
56c67743ab
commit
9ef157b23b
@ -487,22 +487,21 @@ class WorkOrder(Document):
|
|||||||
return
|
return
|
||||||
|
|
||||||
operations = []
|
operations = []
|
||||||
if not self.use_multi_level_bom:
|
|
||||||
|
if self.use_multi_level_bom:
|
||||||
|
bom_tree = frappe.get_doc("BOM", self.bom_no).get_tree_representation()
|
||||||
|
bom_traversal = reversed(bom_tree.level_order_traversal())
|
||||||
|
|
||||||
|
for node in bom_traversal:
|
||||||
|
if node.is_bom:
|
||||||
|
operations.extend(_get_operations(node.name, qty=node.exploded_qty))
|
||||||
|
|
||||||
bom_qty = frappe.db.get_value("BOM", self.bom_no, "quantity")
|
bom_qty = frappe.db.get_value("BOM", self.bom_no, "quantity")
|
||||||
operations.extend(_get_operations(self.bom_no, qty=1.0/bom_qty))
|
operations.extend(_get_operations(self.bom_no, qty=1.0/bom_qty))
|
||||||
else:
|
|
||||||
bom_tree = frappe.get_doc("BOM", self.bom_no).get_tree_representation()
|
|
||||||
bom_traversal = list(reversed(bom_tree.level_order_traversal()))
|
|
||||||
bom_traversal.append(bom_tree) # add operation on top level item last
|
|
||||||
|
|
||||||
for d in bom_traversal:
|
|
||||||
if d.is_bom:
|
|
||||||
operations.extend(_get_operations(d.name, qty=d.exploded_qty))
|
|
||||||
|
|
||||||
for correct_index, operation in enumerate(operations, start=1):
|
for correct_index, operation in enumerate(operations, start=1):
|
||||||
operation.idx = correct_index
|
operation.idx = correct_index
|
||||||
|
|
||||||
|
|
||||||
self.set('operations', operations)
|
self.set('operations', operations)
|
||||||
self.calculate_time()
|
self.calculate_time()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user