From de57e638c2f14a2a634ad03b407db49aa06fe1d6 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 21 Feb 2017 15:01:30 +0100 Subject: [PATCH] [FIX] hr_timesheet: children_hours computation The computation of the `children_hours` wasn't reset at each compute, and they ended up to be added at each recomputation involving the method `_hours_get` This is a regression during migration to the new api in revision e6ac7a7d2571ce046a1d9befd64d4216054494c7 opw-709008 --- addons/hr_timesheet/project_timesheet.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/hr_timesheet/project_timesheet.py b/addons/hr_timesheet/project_timesheet.py index cf2c15af6d2..6a341e851cb 100644 --- a/addons/hr_timesheet/project_timesheet.py +++ b/addons/hr_timesheet/project_timesheet.py @@ -24,12 +24,14 @@ class Task(models.Model): 'child_ids.planned_hours', 'child_ids.effective_hours', 'child_ids.children_hours', 'child_ids.timesheet_ids.unit_amount') def _hours_get(self): for task in self.sorted(key='id', reverse=True): + children_hours = 0 for child_task in task.child_ids: if child_task.stage_id and not child_task.stage_id.fold: - task.children_hours += child_task.effective_hours + child_task.children_hours + children_hours += child_task.effective_hours + child_task.children_hours else: - task.children_hours += max(child_task.planned_hours, child_task.effective_hours + child_task.children_hours) + children_hours += max(child_task.planned_hours, child_task.effective_hours + child_task.children_hours) + task.children_hours = children_hours task.effective_hours = sum(task.timesheet_ids.mapped('unit_amount')) task.remaining_hours = task.planned_hours - task.effective_hours - task.children_hours task.total_hours = max(task.planned_hours, task.effective_hours)