From 76f01bfe8cf2106eade2bcaacd89ed6e9fce142e Mon Sep 17 00:00:00 2001 From: jem-odoo Date: Mon, 3 Dec 2018 12:49:21 +0000 Subject: [PATCH] [FIX] project: better computation of hours to close a task MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, the number of hours the task is open is computed using the resource calendar. The same measure expressed in days simply divide the number of hour by 24. This is not what we intend: we want to know the number of working days since the task was created, and not a simple conversion from hours to days. Task-37561 closes odoo/odoo#30092 Signed-off-by: Jérome Maes (jem) --- addons/project/models/project.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 43fd0da2ab5..86c513695fd 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -548,15 +548,15 @@ class Task(models.Model): if task.date_assign: dt_date_assign = fields.Datetime.from_string(task.date_assign) - task.working_hours_open = task.project_id.resource_calendar_id.get_work_hours_count( - dt_create_date, dt_date_assign, compute_leaves=True) - task.working_days_open = task.working_hours_open / 24.0 + duration_data = task.project_id.resource_calendar_id.get_work_duration_data(dt_create_date, dt_date_assign, compute_leaves=True) + task.working_hours_open = duration_data['hours'] + task.working_days_open = duration_data['days'] if task.date_end: dt_date_end = fields.Datetime.from_string(task.date_end) - task.working_hours_close = task.project_id.resource_calendar_id.get_work_hours_count( - dt_create_date, dt_date_end, compute_leaves=True) - task.working_days_close = task.working_hours_close / 24.0 + duration_data = task.project_id.resource_calendar_id.get_work_duration_data(dt_create_date, dt_date_end, compute_leaves=True) + task.working_hours_close = duration_data['hours'] + task.working_days_close = duration_data['days'] (self - task_linked_to_calendar).update(dict.fromkeys( ['working_hours_open', 'working_hours_close', 'working_days_open', 'working_days_close'], 0.0))