From 013d619c62d415d9022dce450f74b4e10d7bfc2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 17 Oct 2012 16:29:21 +0200 Subject: [PATCH] Fix total_effort computation issue2827 --- work.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/work.py b/work.py index 3cdcc56362..64fdfcfa4d 100644 --- a/work.py +++ b/work.py @@ -206,11 +206,11 @@ class Work(ModelSQL, ModelView): @classmethod def get_total_effort(cls, works, name): - works += cls.search([ + works = cls.search([ ('parent', 'child_of', [w.id for w in works]), ('active', '=', True), - ]) - works = list(set(works)) + ]) + works + works = set(works) res = {} id2work = {} @@ -222,15 +222,20 @@ class Work(ModelSQL, ModelView): leafs.add(work.id) while leafs: - parents = set() for work_id in leafs: work = id2work[work_id] + works.remove(work) if not work.active: continue if work.parent and work.parent.id in res: res[work.parent.id] += res[work_id] - parents.add(work.parent.id) - leafs = parents + next_leafs = set((w.id for w in works)) + for work in 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 return res