From 1b865a06d07c50bb08019525f4cbaecfe9d6bb52 Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Wed, 25 Oct 2023 15:37:10 +0200 Subject: [PATCH] [IMP] mis_builder: Filter period by company --- mis_builder/models/mis_report_instance.py | 5 +++++ mis_builder/readme/CONTRIBUTORS.rst | 1 + mis_builder/views/mis_report_instance.xml | 1 + 3 files changed, 7 insertions(+) diff --git a/mis_builder/models/mis_report_instance.py b/mis_builder/models/mis_report_instance.py index 8627d40dd..116c282a5 100644 --- a/mis_builder/models/mis_report_instance.py +++ b/mis_builder/models/mis_report_instance.py @@ -312,6 +312,7 @@ def _compute_dates(self): default="[]", help="A domain to additionally filter move lines considered in this column.", ) + filter_company_ids = fields.Many2many("res.company") _order = "sequence, id" @@ -424,6 +425,8 @@ def _get_filter_domain_from_context(self): # report-level analytic domain filter if self.analytic_domain: filters.extend(ast.literal_eval(self.analytic_domain)) + if self.filter_company_ids: + filters.extend([("company_id", "in", self.filter_company_ids.ids)]) # contextual analytic domain filter filters.extend(self.env.context.get("mis_analytic_domain", [])) return filters @@ -461,6 +464,8 @@ def _get_additional_move_line_filter(self): ) for tag in self.analytic_tag_ids: domain.append(("analytic_tag_ids", "=", tag.id)) + if self.filter_company_ids: + domain.extend([("company_id", "in", self.filter_company_ids.ids)]) if self.analytic_domain: # Extend the domain with the column-level analytic domain domain.extend(ast.literal_eval(self.analytic_domain)) diff --git a/mis_builder/readme/CONTRIBUTORS.rst b/mis_builder/readme/CONTRIBUTORS.rst index 72531f707..3906aff87 100644 --- a/mis_builder/readme/CONTRIBUTORS.rst +++ b/mis_builder/readme/CONTRIBUTORS.rst @@ -21,6 +21,7 @@ * Arnaud Pineux * Ernesto Tejeda * Pedro M. Baeza +* Enric Tobella * `CorporateHub `__ * Alexey Pelykh diff --git a/mis_builder/views/mis_report_instance.xml b/mis_builder/views/mis_report_instance.xml index 7f464c5c2..f73d37922 100644 --- a/mis_builder/views/mis_report_instance.xml +++ b/mis_builder/views/mis_report_instance.xml @@ -420,6 +420,7 @@ +