Browse Source

[FIX] mis_builder: fix comparison when there are no subkpis (#237)

[FIX] mis_builder: fix comparison when there are no subkpis
pull/239/head
Stéphane Bidoul (ACSONE) 8 years ago
parent
commit
6c89a84792
  1. 14
      mis_builder/models/mis_report.py

14
mis_builder/models/mis_report.py

@ -280,7 +280,7 @@ class KpiMatrix(object):
col = self._cols[col_key] col = self._cols[col_key]
base_col = self._cols[base_col_key] base_col = self._cols[base_col_key]
common_subkpis = set(col.subkpis) & set(base_col.subkpis) common_subkpis = set(col.subkpis) & set(base_col.subkpis)
if not common_subkpis:
if (col.subkpis or base_col.subkpis) and not common_subkpis:
raise UserError('Columns {} and {} are not comparable'. raise UserError('Columns {} and {} are not comparable'.
format(col.description, format(col.description,
base_col.description)) base_col.description))
@ -295,15 +295,19 @@ class KpiMatrix(object):
if cell_tuple is None and base_cell_tuple is None: if cell_tuple is None and base_cell_tuple is None:
continue continue
if cell_tuple is None: if cell_tuple is None:
vals = [AccountingNone] * len(common_subkpis)
vals = [AccountingNone] * \
(len(common_subkpis) or 1)
else: else:
vals = [cell.val for cell in cell_tuple vals = [cell.val for cell in cell_tuple
if cell.subcol.subkpi in common_subkpis]
if not common_subkpis or
cell.subcol.subkpi in common_subkpis]
if base_cell_tuple is None: if base_cell_tuple is None:
base_vals = [AccountingNone] * len(common_subkpis)
base_vals = [AccountingNone] * \
(len(common_subkpis) or 1)
else: else:
base_vals = [cell.val for cell in base_cell_tuple base_vals = [cell.val for cell in base_cell_tuple
if cell.subcol.subkpi in common_subkpis]
if not common_subkpis or
cell.subcol.subkpi in common_subkpis]
comparison_cell_tuple = [] comparison_cell_tuple = []
for val, base_val, comparison_subcol in \ for val, base_val, comparison_subcol in \
izip(vals, izip(vals,

Loading…
Cancel
Save