[FIX] hr_timesheet: avoid rounding error

When adding a timesheet with a number of minute that has many
decimal (once converted into float), the planned_hours field
might be recomputed. So, it might be a rounding error during
this recomputation, making the field value change. Since this
field is tracked, a message is post in chatter (like Planned
Hours: 50 -> 50.0033333"), which is not useful ...

opw-1849693
This commit is contained in:
jem-odoo
2018-05-30 16:22:45 +02:00
parent ed0202df18
commit 7f736f8db6
+1 -1
View File
@@ -30,7 +30,7 @@ class Task(models.Model):
@api.depends('timesheet_ids.unit_amount')
def _compute_effective_hours(self):
for task in self:
task.effective_hours = sum(task.timesheet_ids.mapped('unit_amount'))
task.effective_hours = round(sum(task.timesheet_ids.mapped('unit_amount')), 2)
@api.depends('effective_hours', 'subtask_effective_hours', 'planned_hours')
def _compute_progress_hours(self):