[FIX] project: better computation of hours to close a task

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) <jem@openerp.com>
This commit is contained in:
jem-odoo
2019-08-13 12:16:26 +00:00
parent f499166df0
commit 76f01bfe8c
+6 -6
View File
@@ -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))