Use defaultdict to compute cost and revenue total of project
Since e35820296f3a, sum_tree is use to compute project total but it requires to have a default value for parents that are not in the list of instances. Closes #12305
This commit is contained in:
@@ -62,7 +62,7 @@ class Work(metaclass=PoolMeta):
|
||||
transaction = Transaction()
|
||||
cursor = transaction.connection.cursor()
|
||||
|
||||
costs = dict.fromkeys([w.id for w in works], 0)
|
||||
costs = defaultdict(Decimal)
|
||||
|
||||
table = cls.__table__()
|
||||
work = Work.__table__()
|
||||
@@ -156,7 +156,7 @@ class Work(metaclass=PoolMeta):
|
||||
|
||||
@classmethod
|
||||
def _get_revenue(cls, works):
|
||||
revenues = dict.fromkeys(map(int, works), Decimal(0))
|
||||
revenues = defaultdict(Decimal)
|
||||
for work in works:
|
||||
if not work.list_price:
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user