Skip to content

Commit

Permalink
[FIX] hr_timesheet_overtime_begin_end: Apply rate if times aren't used
Browse files Browse the repository at this point in the history
Signed-off-by: Carmen Bianca BAKKER <[email protected]>
  • Loading branch information
carmenbianca committed Jul 29, 2024
1 parent d861ab0 commit 8b73fbb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 8 additions & 0 deletions hr_timesheet_overtime_begin_end/tests/test_analytic_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 8b73fbb

Please sign in to comment.