From 7f736f8db6863c4a04409c0d4aed8b9154a57aba Mon Sep 17 00:00:00 2001 From: jem-odoo Date: Wed, 30 May 2018 11:16:13 +0200 Subject: [PATCH] [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 --- addons/hr_timesheet/models/project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_timesheet/models/project.py b/addons/hr_timesheet/models/project.py index c88aa12c864..4b36df78e61 100644 --- a/addons/hr_timesheet/models/project.py +++ b/addons/hr_timesheet/models/project.py @@ -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):