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