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 28f3429a54)

Co-authored-by: Mihir Kandoi <kandoimihir@gmail.com>
This commit is contained in:
mergify[bot]
2026-04-19 08:06:09 +00:00
committed by GitHub
parent d542a72da5
commit cfcba1fcf2

View File

@@ -82,7 +82,9 @@ class Workstation(Document):
) )
def before_save(self): 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_hour_rate()
self.set_total_working_hours() self.set_total_working_hours()
self.disabled_workstation() self.disabled_workstation()
@@ -112,9 +114,6 @@ class Workstation(Document):
@frappe.whitelist() @frappe.whitelist()
def set_data_based_on_workstation_type(self): def set_data_based_on_workstation_type(self):
if self.workstation_costs:
return
if self.workstation_type: if self.workstation_type:
data = frappe.get_all( data = frappe.get_all(
"Workstation Cost", "Workstation Cost",
@@ -123,6 +122,9 @@ class Workstation(Document):
order_by="idx", order_by="idx",
) )
if data:
self.workstation_costs = []
for row in data: for row in data:
self.append( self.append(
"workstation_costs", "workstation_costs",