From 1296725eea1f4fba8acbf0b0ea27d3edf0ad836a Mon Sep 17 00:00:00 2001 From: Carmen Bianca BAKKER Date: Thu, 4 Jul 2024 10:34:37 +0200 Subject: [PATCH] [FIX] hr_timesheet_overtime: Preserve default value of unit_amount Signed-off-by: Carmen Bianca BAKKER --- hr_timesheet_overtime/models/account_analytic_line.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hr_timesheet_overtime/models/account_analytic_line.py b/hr_timesheet_overtime/models/account_analytic_line.py index 47b82d8..1e7e26f 100644 --- a/hr_timesheet_overtime/models/account_analytic_line.py +++ b/hr_timesheet_overtime/models/account_analytic_line.py @@ -31,8 +31,10 @@ def _update_values(self, values): Update values if date or unit_amount fields have changed """ if "date" in values or "unit_amount" in values: - # TODO: self.date and self.unit_amount do not exist when called from - # create(). + # If called from create() without unit_amount, don't do anything. + # This preserves the default value. + if not self and "unit_amount" not in values: + return date = values.get("date", self.date) unit_amount = values.get("unit_amount", self.unit_amount) values["unit_amount"] = unit_amount * self.rate_for_date(date)