Problem
When viewing a MIS report instance that belongs to a different company than the user's current company, account codes display as False in auto-expanded account rows. For example, 15050 Loan Fees shows as False Loan Fees.
Root cause
In kpimatrix.py, _load_account_names() reads account.code without the report instance's company context:
def _load_account_names(self):
account_ids = set()
for detail_rows in self._detail_rows.values():
account_ids.update(detail_rows.keys())
accounts = self._account_model.search([("id", "in", list(account_ids))])
self._account_names = {a.id: self._get_account_name(a) for a in accounts}
def _get_account_name(self, account):
result = f"{account.code} {account.name}"
...
In Odoo 18, account.account.code is a company-dependent field backed by code_store (jsonb). When the env doesn't have the correct company context, account.code returns False for accounts belonging to other companies.
KpiMatrix is instantiated at mis_report.py:544 with self.env which uses the current user's company, not the report instance's company:
kpi_matrix = KpiMatrix(self.env, multi_company, self.account_model)
Steps to reproduce
- Create companies A and B, each with their own chart of accounts (with codes)
- Create a MIS report instance for company B with
auto_expand_accounts enabled
- Log in as a user whose current company is A
- View the MIS report instance for company B → account codes show as
False
Expected behavior
Account codes should display correctly regardless of the user's current company.
Environment
- Odoo 18.0 CE
- mis_builder 18.0
- Multi-company setup with separate charts of accounts
Problem
When viewing a MIS report instance that belongs to a different company than the user's current company, account codes display as
Falsein auto-expanded account rows. For example,15050 Loan Feesshows asFalse Loan Fees.Root cause
In
kpimatrix.py,_load_account_names()readsaccount.codewithout the report instance's company context:In Odoo 18,
account.account.codeis a company-dependent field backed bycode_store(jsonb). When theenvdoesn't have the correct company context,account.codereturnsFalsefor accounts belonging to other companies.KpiMatrixis instantiated atmis_report.py:544withself.envwhich uses the current user's company, not the report instance's company:Steps to reproduce
auto_expand_accountsenabledFalseExpected behavior
Account codes should display correctly regardless of the user's current company.
Environment