Browse Source

[IMP] prepare performance optimization to fetch only used balances (WIP)

pull/90/head
Stéphane Bidoul 10 years ago
parent
commit
db7c487ef1
  1. 18
      mis_builder/models/mis_builder.py

18
mis_builder/models/mis_builder.py

@ -68,6 +68,17 @@ def _python_bal_var(account_code):
return 'bal_' + re.sub(r'\W', '_', account_code) return 'bal_' + re.sub(r'\W', '_', account_code)
def _get_bal_vars_in_expr(expr):
return re.findall(expr, r'\bbal_\w+')
def _get_vars_in_expr(expr, varnames=None):
if not varnames:
return []
varnames_re = r'\b' + r'\b|\b'.join(varnames) + r'\b'
return re.findall(expr, varnames_re)
class mis_report_kpi(orm.Model): class mis_report_kpi(orm.Model):
""" A KPI is an element of a MIS report. """ A KPI is an element of a MIS report.
@ -548,6 +559,13 @@ class mis_report_instance_period(orm.Model):
return res return res
def _get_bal_vars_in_report(self, report):
res = set()
for kpi in report.kpi_ids:
for bal_var in _get_bal_vars_in_expr(kpi.expression):
res.add(bal_var)
return res
def _compute(self, cr, uid, c, context=None): def _compute(self, cr, uid, c, context=None):
if context is None: if context is None:
context = {} context = {}

Loading…
Cancel
Save