From 2777b774957e0ed61d71bc4b167de283c3f45a73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 17 Oct 2012 16:30:38 +0200 Subject: [PATCH] Fix duration computation issue2827 (transplanted from 32fe04afe37c0978121f6fc22c777d45636c1fdb) --- work.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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