diff --git a/hr_timesheet_overtime_begin_end/models/account_analytic_line.py b/hr_timesheet_overtime_begin_end/models/account_analytic_line.py index 6e5eae2..2f5c760 100644 --- a/hr_timesheet_overtime_begin_end/models/account_analytic_line.py +++ b/hr_timesheet_overtime_begin_end/models/account_analytic_line.py @@ -26,7 +26,12 @@ class AnalyticLine(models.Model): # functions instead of the aforementioned methods. @api.model def _update_values(self, values): - return + time_start = values.get("time_start", self.time_start) + time_stop = values.get("time_stop", self.time_stop) + # Do not double-compute if we're using times. + if time_start or time_stop: + return + return super()._update_values(values) def unit_amount_from_start_stop(self): result = super().unit_amount_from_start_stop() diff --git a/hr_timesheet_overtime_begin_end/tests/test_analytic_line.py b/hr_timesheet_overtime_begin_end/tests/test_analytic_line.py index 60d742c..af141ff 100644 --- a/hr_timesheet_overtime_begin_end/tests/test_analytic_line.py +++ b/hr_timesheet_overtime_begin_end/tests/test_analytic_line.py @@ -64,3 +64,11 @@ def test_rate_not_double_applied(self): # The rate was already applied on the transient record. Don't also apply # it on creation. self.assertEqual(line_record.unit_amount, 4.0) + + def test_rate_applied_if_no_times(self): + line = self.base_line() + del line["time_start"] + del line["time_stop"] + line["unit_amount"] = 1 + line_record = self.env["account.analytic.line"].create(line) + self.assertEqual(line_record.unit_amount, 2)