Skip to content

Commit cfcba1f

Browse files
fix: recalculate operating costs if workstation type is changed (backport #54390) (#54398)
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 (cherry picked from commit 28f3429) Co-authored-by: Mihir Kandoi <kandoimihir@gmail.com>
1 parent d542a72 commit cfcba1f

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

erpnext/manufacturing/doctype/workstation/workstation.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ def validate_duplicate_operating_component(self):
8282
)
8383

8484
def before_save(self):
85-
self.set_data_based_on_workstation_type()
85+
if self.has_value_changed("workstation_type"):
86+
self.set_data_based_on_workstation_type()
87+
8688
self.set_hour_rate()
8789
self.set_total_working_hours()
8890
self.disabled_workstation()
@@ -112,9 +114,6 @@ def set_hour_rate(self):
112114

113115
@frappe.whitelist()
114116
def set_data_based_on_workstation_type(self):
115-
if self.workstation_costs:
116-
return
117-
118117
if self.workstation_type:
119118
data = frappe.get_all(
120119
"Workstation Cost",
@@ -123,6 +122,9 @@ def set_data_based_on_workstation_type(self):
123122
order_by="idx",
124123
)
125124

125+
if data:
126+
self.workstation_costs = []
127+
126128
for row in data:
127129
self.append(
128130
"workstation_costs",

0 commit comments

Comments
 (0)