Browse Source

[IMP] prepare_locals_dict (#199)

pull/231/head
Thomas Binsfeld 9 years ago
committed by Stéphane Bidoul (ACSONE)
parent
commit
9af17587fc
  1. 30
      mis_builder/models/mis_report.py

30
mis_builder/models/mis_report.py

@ -797,6 +797,17 @@ class MisReport(models.Model):
aep.done_parsing()
return aep
def prepare_locals_dict(self):
return {
'sum': _sum,
'min': _min,
'max': _max,
'len': len,
'avg': _avg,
'AccountingNone': AccountingNone,
'SimpleArray': SimpleArray,
}
@api.multi
def _fetch_queries(self, date_from, date_to,
get_additional_query_filter=None):
@ -874,7 +885,8 @@ class MisReport(models.Model):
target_move,
subkpis_filter=None,
get_additional_move_line_filter=None,
get_additional_query_filter=None):
get_additional_query_filter=None,
locals_dict=None):
""" Evaluate a report for a given period, populating a KpiMatrix.
:param kpi_matrix: the KpiMatrix object to be populated created
@ -892,18 +904,16 @@ class MisReport(models.Model):
query argument and returns a
domain compatible with the query
underlying model
:param locals_dict: personalized locals dictionary used as evaluation
context for the KPI expressions
"""
self.ensure_one()
locals_dict = {
'sum': _sum,
'min': _min,
'max': _max,
'len': len,
'avg': _avg,
'AccountingNone': AccountingNone,
'SimpleArray': SimpleArray,
}
# prepare the localsdict
if locals_dict is None:
locals_dict = {}
locals_dict.update(self.prepare_locals_dict())
# fetch non-accounting queries
locals_dict.update(self._fetch_queries(

Loading…
Cancel
Save