From 28f3429a5409ced9afdbac748ecfacf7658c9109 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Sun, 19 Apr 2026 13:13:48 +0530 Subject: [PATCH] fix: recalculate operating costs if workstation type is changed (#54390) * fix: recalculate operating costs if workstation type is changed * fix: do not overwrite op costs on every save --- .../manufacturing/doctype/workstation/workstation.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/erpnext/manufacturing/doctype/workstation/workstation.py b/erpnext/manufacturing/doctype/workstation/workstation.py index 710a36d2d68..60c50631847 100644 --- a/erpnext/manufacturing/doctype/workstation/workstation.py +++ b/erpnext/manufacturing/doctype/workstation/workstation.py @@ -83,7 +83,9 @@ class Workstation(Document): ) def before_save(self): - self.set_data_based_on_workstation_type() + if self.has_value_changed("workstation_type"): + self.set_data_based_on_workstation_type() + self.set_hour_rate() self.set_total_working_hours() self.disabled_workstation() @@ -113,9 +115,6 @@ class Workstation(Document): @frappe.whitelist() def set_data_based_on_workstation_type(self): - if self.workstation_costs: - return - if self.workstation_type: data = frappe.get_all( "Workstation Cost", @@ -124,6 +123,9 @@ class Workstation(Document): order_by="idx", ) + if data: + self.workstation_costs = [] + for row in data: self.append( "workstation_costs",