Browse Source

[IMP] mis_builder: recompute on ValueError

so kpi can be displayed in an other sequence than the computation dependency order
pull/86/head
Stéphane Bidoul 10 years ago
parent
commit
bae95527e1
  1. 22
      mis_builder/models/mis_builder.py

22
mis_builder/models/mis_builder.py

@ -622,7 +622,10 @@ class mis_report_instance_period(orm.Model):
localdict.update(self._fetch_queries(cr, uid, c, localdict.update(self._fetch_queries(cr, uid, c,
context=context)) context=context))
for kpi in c.report_instance_id.report_id.kpi_ids:
compute_queue = c.report_instance_id.report_id.kpi_ids
recompute_queue = []
while True:
for kpi in compute_queue:
try: try:
kpi_val_comment = kpi.expression kpi_val_comment = kpi.expression
kpi_eval_expression = aep.replace_expr(kpi.expression) kpi_eval_expression = aep.replace_expr(kpi.expression)
@ -631,6 +634,11 @@ class mis_report_instance_period(orm.Model):
kpi_val = None kpi_val = None
kpi_val_rendered = '#DIV/0' kpi_val_rendered = '#DIV/0'
kpi_val_comment += '\n\n%s' % (traceback.format_exc(),) kpi_val_comment += '\n\n%s' % (traceback.format_exc(),)
except ValueError:
recompute_queue.append(kpi)
kpi_val = None
kpi_val_rendered = '#ERR'
kpi_val_comment += '\n\n%s' % (traceback.format_exc(),)
except: except:
kpi_val = None kpi_val = None
kpi_val_rendered = '#ERR' kpi_val_rendered = '#ERR'
@ -660,6 +668,18 @@ class mis_report_instance_period(orm.Model):
'period_name': c.name, 'period_name': c.name,
} }
if len(recompute_queue) == 0:
# nothing to recompute, we are done
break
if len(recompute_queue) == len(compute_queue):
# could not compute anything in this iteration
# (ie real Value errors or cyclic dependency)
# so we stop trying
break
# try again
compute_queue = recompute_queue
recompute_queue = []
return res return res

Loading…
Cancel
Save