fix: fetch hour rate from workstation when operation hour_rate is mis… (#54820)

fix: fetch hour rate from workstation when operation hour_rate is missing
This commit is contained in:
Pandiyan P
2026-05-11 13:18:51 +05:30
committed by GitHub
parent 6eaf92aae6
commit d57ec6c094

View File

@@ -324,6 +324,10 @@ class WorkOrder(Document):
def calculate_operating_cost(self):
self.planned_operating_cost, self.actual_operating_cost = 0.0, 0.0
for d in self.get("operations"):
if not d.hour_rate:
if d.workstation:
d.hour_rate = get_hour_rate(d.workstation)
d.planned_operating_cost = flt(
flt(d.hour_rate) * (flt(d.time_in_mins) / 60.0), d.precision("planned_operating_cost")
)
@@ -1895,3 +1899,8 @@ def make_stock_return_entry(work_order):
stock_entry.set_stock_entry_type()
return stock_entry
@frappe.request_cache
def get_hour_rate(workstation):
return frappe.get_cached_value("Workstation", workstation, "hour_rate") or 0.0