Skip to content

[18.0][FIX] account_financial_report: limit unaffected_earnings_account search to one - #2

Open
dnplkndll wants to merge 2 commits into
18.0from
18.0-fix-unaffected-earnings-limit
Open

dnplkndll wants to merge 2 commits into
18.0from
18.0-fix-unaffected-earnings-limit

Conversation

@dnplkndll

Copy link
Copy Markdown

What

_compute_unaffected_earnings_account in trial_balance_wizard and general_ledger_wizard assigns to a Many2one field (store=True), but the search domain on account.account.company_ids can match multiple records in multi-company setups (an equity_unaffected account typically exists per company). Without limit=1, the assignment raises:

ValueError: Wrong value for <wizard>.unaffected_earnings_account: account.account(X, Y)

This PR adds limit=1 to both wizards.

Why

The Many2one write strictly rejects multi-record values in modern Odoo ORM (any leniency older versions had no longer applies). The bug surfaces deterministically once a second company with an equity_unaffected account exists — the existing _only_one_unaffected_earnings_account helper in both wizards even acknowledges this case but the compute itself doesn't honor it.

19.0 is unaffected — the compute was refactored upstream to delegate to res.company.get_unaffected_earnings_account().

How

Two-line change, one per wizard. No behavior change in single-company environments.

Fork-mirror note

Opened against the ledoent fork's 18.0 first so it can be reviewed before being submitted as [18.0][FIX] to OCA/account-financial-reporting. The branch (18.0-fix-unaffected-earnings-limit) is based on OCA/18.0 head; the identical commit will go upstream once approved here.

dnplkndll added 2 commits May 18, 2026 14:04
…nt search to one

_compute_unaffected_earnings_account in trial_balance_wizard and
general_ledger_wizard assigns a Many2one field but the search domain
("company_ids", "in", ...) on account.account can match multiple
records in multi-company setups (equity_unaffected accounts typically
exist per company). Without limit=1 the assignment raises:

  ValueError: Wrong value for <wizard>.unaffected_earnings_account:
              account.account(X, Y)

Add limit=1 to both wizards. The 19.0 branch is unaffected because
the compute was refactored to delegate to
res.company.get_unaffected_earnings_account().

Signed-off-by: Don Kendall <dkendall@ledoweb.com>
…ted_earnings_account search

Add order="id" to the limit=1 search in both wizards so the result is
stable when a company has multiple equity_unaffected accounts, rather
than depending on Postgres row order.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant