From f18313f51260ac46d4991db47a28f92676f53d19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Bernabeu?= Date: Mon, 10 Nov 2025 11:47:44 +0100 Subject: [PATCH] [FIX][18.0] mis_builder: Error in multicompany report MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Description of the issue/feature this PR addresses: Current behavior before PR: When we have two companies selected, and we go to Invoicing > Reporting > MIS reports, select a report template, check ‘Multiple companies’ and click on preview, we get an error message. Desired behavior after PR is merged: The error no longer appears and the preview is displayed correctly. ADD: When we have multiple companies but only one is selected in the context, the report should not display the company name. This fix ensures the company name is only shown when more than one company is active. @moduon MT-11000 --- mis_builder/models/kpimatrix.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mis_builder/models/kpimatrix.py b/mis_builder/models/kpimatrix.py index dc23b12a7..e929b0884 100644 --- a/mis_builder/models/kpimatrix.py +++ b/mis_builder/models/kpimatrix.py @@ -159,6 +159,7 @@ def __init__(self, env, multi_company=False, account_model="account.account"): # { account_id: account_name } self._account_names = {} self._multi_company = multi_company + self._env = env def declare_kpi(self, kpi): """Declare a new kpi (row) in the matrix. @@ -468,8 +469,12 @@ def _load_account_names(self): def _get_account_name(self, account): result = f"{account.code} {account.name}" - if self._multi_company: - result = f"{result} [{account.company_id.name}]" + if not account.code: + account = account.with_company(account.company_ids[0]) + result = f"{account.code} {account.name}" + if self._multi_company and account.company_ids and len(self._env.companies) > 1: + company_names = ", ".join(account.company_ids.mapped("name")) + result = f"{result} [{company_names}]" return result def get_account_name(self, account_id):