Skip to content

Commit

Permalink
[IMP] mis_builder: make description of hide_period_based_on_instance_…
Browse files Browse the repository at this point in the history
…date mor 'explanatory'

[IMP] mis_builder: cleanup code
  • Loading branch information
AnizR committed Oct 15, 2024
1 parent aa976ee commit bcbded6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
23 changes: 8 additions & 15 deletions mis_builder/models/mis_report_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion mis_builder/views/mis_report_instance.xml
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,10 @@
options="{'model': 'source_aml_model_name'}"
attrs="{'invisible': [('source_aml_model_name', '=', False)]}"
/>
<field name="hide_period_based_on_instance_date" />
<field
name="hide_period_based_on_instance_date"
attrs="{'invisible': [('source', '=', cmpcol)]}"
/>
</group>
</form>
</field>
Expand Down

0 comments on commit bcbded6

Please sign in to comment.