Skip to content

[18.0][BUG] Account codes show as 'False' in auto_expand_accounts for multi-company reports #779

@dnplkndll

Description

@dnplkndll

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

  1. Create companies A and B, each with their own chart of accounts (with codes)
  2. Create a MIS report instance for company B with auto_expand_accounts enabled
  3. Log in as a user whose current company is A
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions