Skip to content

Commit

Permalink
[FIX] applied sbidoul comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sa3m committed Oct 5, 2023
1 parent c388fe2 commit 38c7949
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
10 changes: 5 additions & 5 deletions mis_builder/models/kpimatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,19 +432,19 @@ def compute_sums(self):
tooltips=False,
)

def iter_rows(self, inverse_detail=False):
def iter_rows(self, details_before_kpi=False):
"""Iterate rows in display order.
yields KpiMatrixRow.
"""
for kpi_row in self._kpi_rows.values():
if not inverse_detail:
if not details_before_kpi:
yield kpi_row
detail_rows = self._detail_rows[kpi_row.kpi].values()
detail_rows = sorted(detail_rows, key=lambda r: r.label)
for detail_row in detail_rows:
yield detail_row
if inverse_detail:
if details_before_kpi:
yield kpi_row

def iter_cols(self):
Expand Down Expand Up @@ -483,7 +483,7 @@ def get_account_name(self, account_id):
self._load_account_names()
return self._account_names[account_id]

def as_dict(self, inverse_detail=False):
def as_dict(self, details_before_kpi=False):
header = [{"cols": []}, {"cols": []}]
for col in self.iter_cols():
header[0]["cols"].append(
Expand All @@ -503,7 +503,7 @@ def as_dict(self, inverse_detail=False):
)

body = []
for row in self.iter_rows(inverse_detail=inverse_detail):
for row in self.iter_rows(details_before_kpi=details_before_kpi):
if (
row.style_props.hide_empty and row.is_empty()
) or row.style_props.hide_always:
Expand Down
6 changes: 3 additions & 3 deletions mis_builder/models/mis_report_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,8 @@ def _compute_pivot_date(self):
display_columns_description = fields.Boolean(
help="Display the date range details in the column headers."
)
inverse_detail = fields.Boolean(
help="Show detail before KPI.",
details_before_kpi = fields.Boolean(
help="Show account details before KPI.",
)
comparison_mode = fields.Boolean(
compute="_compute_comparison_mode", inverse="_inverse_comparison_mode"
Expand Down Expand Up @@ -872,7 +872,7 @@ def _compute_matrix(self):
def compute(self):
self.ensure_one()
kpi_matrix = self._compute_matrix()
return kpi_matrix.as_dict(inverse_detail=self.inverse_detail)
return kpi_matrix.as_dict(details_before_kpi=self.details_before_kpi)

def drilldown(self, arg):
self.ensure_one()
Expand Down
2 changes: 1 addition & 1 deletion mis_builder/report/mis_report_instance_qweb.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
</div>
<div class="mis_tbody">
<t
t-foreach="matrix.iter_rows(o.inverse_detail)"
t-foreach="matrix.iter_rows(o.details_before_kpi)"
t-as="row"
>
<div
Expand Down
2 changes: 1 addition & 1 deletion mis_builder/report/mis_report_instance_xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def generate_xlsx_report(self, workbook, data, objects):
row_pos += 1

# rows
for row in matrix.iter_rows(objects.inverse_detail):
for row in matrix.iter_rows(objects.details_before_kpi):
if (
row.style_props.hide_empty and row.is_empty()
) or row.style_props.hide_always:
Expand Down
1 change: 1 addition & 0 deletions mis_builder/views/mis_report_instance.xml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
<group name="layout">
<field name="landscape_pdf" />
<field name="no_auto_expand_accounts" />
<field name="details_before_kpi" attrs="{'invisible': [('no_auto_expand_accounts', '=', True)]}" />
<field name="display_columns_description" />
<field name="hide_analytic_filters" />
<field name="inverse_detail" />
Expand Down

0 comments on commit 38c7949

Please sign in to comment.