Browse Source

[IMP] mis_builder: tiny refactoring

pull/86/head
Stéphane Bidoul 10 years ago
parent
commit
615e67e02a
  1. 1
      mis_builder/models/aep.py
  2. 12
      mis_builder/models/mis_builder.py

1
mis_builder/models/aep.py

@ -155,6 +155,7 @@ class AccountingExpressionProcessor(object):
account_ids.update(self._account_ids_by_code[account_code])
self._map_account_ids[key] = list(account_ids)
@classmethod
def has_account_var(self, expr):
return bool(self.ACC_RE.search(expr))

12
mis_builder/models/mis_builder.py

@ -35,7 +35,7 @@ from openerp import tools
from openerp.tools.safe_eval import safe_eval
from openerp.tools.translate import _
from .aep import AccountingExpressionProcessor
from .aep import AccountingExpressionProcessor as AEP
class AutoStruct(object):
@ -457,9 +457,9 @@ class mis_report_instance_period(orm.Model):
if context is None:
context = {}
this = self.browse(cr, uid, _id, context=context)[0]
env = Environment(cr, uid, context)
aep = AccountingExpressionProcessor(env)
if aep.has_account_var(expr):
if AEP.has_account_var(expr):
env = Environment(cr, uid, context)
aep = AEP(env)
aep.parse_expr(expr)
aep.done_parsing(this.report_instance_id.root_account)
domain = aep.get_aml_domain_for_expr(
@ -585,7 +585,7 @@ class mis_report_instance_period(orm.Model):
kpi_style = None
drilldown = (kpi_val is not None and
aep.has_account_var(kpi.expression))
AEP.has_account_var(kpi.expression))
res[kpi.name] = {
'val': kpi_val,
@ -702,7 +702,7 @@ class mis_report_instance(orm.Model):
# prepare AccountingExpressionProcessor
env = Environment(cr, uid, context)
aep = AccountingExpressionProcessor(env)
aep = AEP(env)
for kpi in this.report_id.kpi_ids:
aep.parse_expr(kpi.expression)
aep.done_parsing(this.root_account)

Loading…
Cancel
Save