Fix duration computation

issue2827
(transplanted from 32fe04afe37c0978121f6fc22c777d45636c1fdb)
This commit is contained in:
Cédric Krier committed 2012-10-17 16:30:38 +02:00
1 parent eaadebdfa0
commit 2777b77495
1 file changed
+9 -3
+9 -3
View File
@@ -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