Merge pull request #50406 from rohitwaghchaure/fixed-github-48153

fix: set operating cost based on bom qty causing incorrect operating …
This commit is contained in:
rohitwaghchaure
2025-11-07 23:13:43 +05:30
committed by GitHub
2 changed files with 15 additions and 4 deletions

View File

@@ -836,7 +836,7 @@ class BOM(WebsiteGenerator):
self.base_operating_cost = 0
if self.get("with_operations"):
for d in self.get("operations"):
if d.workstation:
if d.workstation or d.workstation_type:
self.update_rate_and_time(d, update_hour_rate)
operating_cost = d.operating_cost
@@ -857,7 +857,13 @@ class BOM(WebsiteGenerator):
def update_rate_and_time(self, row, update_hour_rate=False):
if not row.hour_rate or update_hour_rate:
hour_rate = flt(frappe.get_cached_value("Workstation", row.workstation, "hour_rate"))
hour_rate = 0
if row.workstation:
hour_rate = flt(frappe.get_cached_value("Workstation", row.workstation, "hour_rate"))
elif row.workstation_type:
hour_rate = flt(
frappe.get_cached_value("Workstation Type", row.workstation_type, "hour_rate")
)
if hour_rate:
row.hour_rate = (

View File

@@ -1234,13 +1234,18 @@ class WorkOrder(Document):
"fixed_time",
"skip_material_transfer",
"backflush_from_wip_warehouse",
"set_cost_based_on_bom_qty",
],
order_by="idx",
)
for d in data:
if not d.fixed_time:
d.time_in_mins = flt(d.time_in_mins) * flt(qty)
if d.set_cost_based_on_bom_qty:
d.time_in_mins = flt(d.time_in_mins) * flt(flt(qty) / flt(d.batch_size or 1))
else:
d.time_in_mins = flt(d.time_in_mins) * flt(qty)
d.status = "Pending"
if self.track_semi_finished_goods and not d.sequence_id:
@@ -1263,7 +1268,7 @@ class WorkOrder(Document):
operations.extend(_get_operations(node.name, qty=node.exploded_qty / node.bom_qty))
bom_qty = frappe.get_cached_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=bom_qty))
for correct_index, operation in enumerate(operations, start=1):
operation.idx = correct_index