From 8e34261c01fc9b23d11e78e62b79b9df73a0a4be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Sat, 30 Apr 2016 14:35:12 +0200 Subject: [PATCH] [FIX] mis_builder: fixes wrt subkpis and drilldown --- mis_builder/models/aep.py | 2 +- mis_builder/models/mis_builder.py | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/mis_builder/models/aep.py b/mis_builder/models/aep.py index 69f1a07b..fbfacd8a 100644 --- a/mis_builder/models/aep.py +++ b/mis_builder/models/aep.py @@ -191,7 +191,7 @@ class AccountingExpressionProcessor(object): fy_date_from = \ company.compute_fiscalyear_dates(date_from_date)['date_from'] domain = ['|', - ('date', '>=', fy_date_from), + ('date', '>=', fields.Date.to_string(fy_date_from)), ('user_type_id.include_initial_balance', '=', True)] if mode == MODE_INITIAL: domain.append(('date', '<', date_from)) diff --git a/mis_builder/models/mis_builder.py b/mis_builder/models/mis_builder.py index c86d7b1b..07f2be34 100644 --- a/mis_builder/models/mis_builder.py +++ b/mis_builder/models/mis_builder.py @@ -978,7 +978,6 @@ class MisReportInstancePeriod(models.Model): 'dp': kpi.dp, 'is_percentage': kpi.type == 'pct', 'period_id': self.id, - 'expr': kpi.expression, # TODO FIXME 'style': '', 'xlsx_style': {}, } @@ -998,24 +997,28 @@ class MisReportInstancePeriod(models.Model): 'drilldown': False, }) else: - # TODO FIXME: has_account_var on each subkpi expression? - drilldown = (subkpi_val is not AccountingNone and - AEP.has_account_var(kpi.expression)) if kpi.multi: expression = kpi.expression_ids[idx].name + comment = '{}.{} = {}'.format( + kpi.name, + kpi.expression_ids[idx].subkpi_id.name, + expression) else: expression = kpi.expression - # TODO FIXME: check we have meaningfulname for exploded - # kpis - comment = kpi.name + " = " + expression + comment = '{} = {}'.format( + kpi.name, + expression) + drilldown = (subkpi_val is not AccountingNone and + AEP.has_account_var(expression)) vals.update({ 'val': (None if subkpi_val is AccountingNone else subkpi_val), 'val_r': kpi.render(lang_id, subkpi_val), 'val_c': comment, + 'expr': expression, 'drilldown': drilldown, - }) + }) res[kpi_name].append(vals) return res