diff --git a/mis_builder/models/mis_report_instance.py b/mis_builder/models/mis_report_instance.py
index 87e8c6f61..ea6b13e68 100644
--- a/mis_builder/models/mis_report_instance.py
+++ b/mis_builder/models/mis_report_instance.py
@@ -285,7 +285,8 @@ def _compute_dates(self):
)
hide_period_based_on_instance_date = fields.Boolean(
- help="Dynamically hide this period depending on the base date of the instance",
+ string="Dynamically Hide Period",
+ help="Hide this period if the pivot date is before the end date",
)
_order = "sequence, id"
@@ -848,17 +849,11 @@ def _add_column(self, aep, kpi_matrix, period, label, description):
return self._add_column_cmpcol(aep, kpi_matrix, period, label, description)
def _get_periods(self):
- periods = self.env["mis.report.instance.period"]
-
- for period in self.period_ids:
- if (
- period.hide_period_based_on_instance_date
- and self.pivot_date < period.date_to
- ):
- continue
- periods += period
-
- return periods
+ return self.period_ids.filtered(
+ lambda rec: not (
+ rec.hide_period_based_on_instance_date and self.pivot_date < rec.date_to
+ )
+ )
def _compute_matrix(self):
"""Compute a report and return a KpiMatrix.
@@ -870,9 +865,7 @@ def _compute_matrix(self):
aep = self.report_id._prepare_aep(self.query_company_ids, self.currency_id)
kpi_matrix = self.report_id.prepare_kpi_matrix(self.multi_company)
- periods = self._get_periods()
-
- for period in periods:
+ for period in self._get_periods():
description = None
if period.mode == MODE_NONE:
pass
diff --git a/mis_builder/views/mis_report_instance.xml b/mis_builder/views/mis_report_instance.xml
index 20ac73b61..c6b4db56f 100644
--- a/mis_builder/views/mis_report_instance.xml
+++ b/mis_builder/views/mis_report_instance.xml
@@ -414,7 +414,10 @@
options="{'model': 'source_aml_model_name'}"
attrs="{'invisible': [('source_aml_model_name', '=', False)]}"
/>
-
+