diff --git a/work.py b/work.py index 4c58d38a9e..e676f7f54f 100644 --- a/work.py +++ b/work.py @@ -121,6 +121,7 @@ class Work(ModelSQL, ModelView): all_ids = list(set(all_ids)) works = self.browse(cursor, user, all_ids, context=context) + all_works = set(works) durations = {} id2work = {} @@ -139,15 +140,20 @@ class Work(ModelSQL, ModelView): durations[work.id] = work.effort / (total_allocation / 100.0) while leafs: - parents = set() for work_id in leafs: work = id2work[work_id] + all_works.remove(work) if not work.active: continue if work.parent and work.parent.id in durations: durations[work.parent.id] += durations[work_id] - parents.add(work.parent.id) - leafs = parents + next_leafs = set(w.id for w in all_works) + for work in all_works: + if not work.parent: + continue + if work.parent.id in next_leafs and work.parent in works: + next_leafs.remove(work.parent.id) + leafs = next_leafs res['duration'] = durations