From d57ec6c0949c4dc9ccbc2d757b254789311c9856 Mon Sep 17 00:00:00 2001 From: Pandiyan P Date: Mon, 11 May 2026 13:18:51 +0530 Subject: [PATCH] =?UTF-8?q?fix:=20fetch=20hour=20rate=20from=20workstation?= =?UTF-8?q?=20when=20operation=20hour=5Frate=20is=20mis=E2=80=A6=20(#54820?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: fetch hour rate from workstation when operation hour_rate is missing --- erpnext/manufacturing/doctype/work_order/work_order.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/erpnext/manufacturing/doctype/work_order/work_order.py b/erpnext/manufacturing/doctype/work_order/work_order.py index 2de6f934a15..0584320726f 100644 --- a/erpnext/manufacturing/doctype/work_order/work_order.py +++ b/erpnext/manufacturing/doctype/work_order/work_order.py @@ -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