Repository navigation
[13.0][OU-FIX] l10n_es: keep the accounts of group taxes - #6047
Merged
pedrobaeza merged 1 commit intoOct 1, 2026
Merged
Conversation
Up to 12.0 the reverse charge and intra-community purchase taxes of l10n_es are group taxes: the group holds no account, and its two children hold 472 and 477. The repartition lines created for each group took their account from the group itself, so the tax lines were left without one, and a bill posted after the migration put both tax amounts on the expense account of its line. Give each tax repartition line of the group the account of its child's one, matched by repartition type and sign, as the move lines are matched to their repartition line a few lines below. Assisted-by: Claude Opus 5.5
grojof
added a commit
to grojof/odoo_dev_workspace_generator
that referenced
this pull request
Sep 30, 2026
…r 13.0 (#52) * feat(migrate): give former group taxes their children's accounts after 13.0 OpenUpgrade 13.0 turns a localisation's group taxes (reverse charge, intra-community purchases) into one tax and takes its repartition lines' account from the group, which holds none: a bill posted after the migration puts both tax amounts on the expense account of its line. For a source up to 12.0, right after the 13.0 step, each such line takes the account of its child's repartition line, matched by document, type and sign. Proposed upstream as OCA/OpenUpgrade#6047; once OpenUpgrade sets them, nothing is written. * docs(openspec): archive keep-group-tax-accounts after the real-host run
pedrobaeza
approved these changes
Oct 1, 2026
pedrobaeza
left a comment
Member
There was a problem hiding this comment.
You have to avoid the so verbose explanation and go to the point, but let's add this extra query for fine-graining the conversion although you should run account_chart_update after.
grojof
added a commit
to grojof/odoo_dev_workspace_generator
that referenced
this pull request
Oct 1, 2026
OCA/OpenUpgrade#6047 was merged on 2026-10-01. Say so where the repair is described, and that account_chart_update is still run once, at the target.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Module
l10n_es (12.0 -> 13.0)
The bug
Up to 12.0, the reverse charge and intra-community purchase taxes of
l10n_esare group taxes. Thegroup holds no account; its two children hold them (472 for the deductible side, 477 for the
self-assessed side). In 13.0 each of them is a single tax with repartition lines.
use_new_taxes_and_repartition_lines_on_move_linescreates those repartition lines for the 15 grouptaxes, and takes their account from the group itself:
A group tax has no account, so the four tax repartition lines of each of the 15 taxes are left without
one. After the migration:
472 and 477 are not moved.
Nothing fails and the tax amounts are right, so it is easy to miss.
Why not leave it to
account_chart_updateOn 13.0,
account_chart_updatewith "Update Tax Accounts" does fill these accounts, and a databasethat runs it right after this step does not see the problem. Three things still make me think the
migration should keep them itself:
child tax (say 472001) gets 472000 from the wizard; with this change the migration keeps 472001.
the bill still posts both amounts on the expense account.
("Distribution") and stops with a
ForeignKeyViolationonaccount_move_line_tax_repartition_line_id_fkey, since it replaces the repartition lines the journalitems point at. With this change that tax shows no difference in its distribution, and the wizard
applies.
The fix
Once the group's repartition lines exist, give each tax line the account of its child's repartition
line, matched by repartition type and sign. It is the match the same function already uses, a few lines
below, to move the journal items from the child's repartition line to the group's.
Only lines without an account are written.
To reproduce
Affected versions: 12.0 -> 13.0 (OpenUpgrade 13.0 at 489d722; OCB 12.0 at 4b525526)
l10n_es, without demo data:odoo-bin -d repro -i l10n_es --without-demo=all --stop-after-initodoo-bin shell, post a vendor bill with an intra-community tax:odoo-bin -d repro --update all --stop-after-initodoo-bin shell(13.0), post the same bill again:With it: 600000 1000/0, 472000 210/0, 477000 0/210, 410000 0/1000, as in 12.0.
Checks
On that database, migrated once without the fix and once with it:
account;
l10n_esfor each of the 15 taxes;The points about
account_chart_updatewere run too: on 13.0 on that database, with the wizard at4d0c3d8 (the own account was set on the child tax in 12.0, before migrating); and on 18.0 on the same
database with the company's country set to Spain in 12.0, carried on with OpenUpgrade and OCB 14.0 to
18.0 (core modules only), with the wizard at e4c1b86.
This contribution was prepared with AI assistance (Claude Opus 5.5), and reviewed and tested by me. The
commit carries an
Assisted-by:trailer, per the OCA AI policy.