Browse Source

[FIX] avoid division by 0

pull/90/head
jbeficent 9 years ago
committed by Stéphane Bidoul
parent
commit
e6ecd5b245
  1. 6
      mis_builder/models/mis_builder.py

6
mis_builder/models/mis_builder.py

@ -599,11 +599,11 @@ class MisReportInstancePeriod(orm.Model):
cr, uid, obj_ids, field_names, context=context)
s = AutoStruct(count=len(data))
if query.aggregate == 'min':
agg = min
agg = _min
elif query.aggregate == 'max':
agg = max
agg = _max
elif query.aggregate == 'avg':
agg = lambda l: sum(l) / float(len(l))
agg = _avg
for field_name in field_names:
setattr(s, field_name,
agg([d[field_name] for d in data]))

Loading…
Cancel
Save