[16.0][OU-ADD] ptplus: keep the abandoned PT-RF CD tax tags the vendor forgot to migrate#20
Open
eantones wants to merge 1 commit into
Open
[16.0][OU-ADD] ptplus: keep the abandoned PT-RF CD tax tags the vendor forgot to migrate#20eantones wants to merge 1 commit into
eantones wants to merge 1 commit into
Conversation
eantones
force-pushed
the
16.0-ou-add-ptplus
branch
3 times, most recently
from
July 17, 2026 16:08
093fe3c to
db9aebf
Compare
…egacy namespace; let the GC drop the unused ones
eantones
force-pushed
the
16.0-ou-add-ptplus
branch
from
July 20, 2026 22:28
db9aebf to
02ff451
Compare
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.
Problem
At the 15→16 hop,
_process_end(Odoo's orphan-xmlid garbage collector) tries toDELETEa batch ofaccount.account.tagrows and fails:Historical accounting entries and tax repartition lines still reference these tags by FK, so the delete is refused. The
-u allcompletes (exit 0) but the wrapper turns the hop RED, and the same path is a FATAL at the 18 settle.Root cause (archaeology, verified on ptplus 15.0/16.0/17.0/18.0/19.0)
Through 15.0, ptplus classifies PT withholding on move lines with per-payment-guide-code TAGS:
PT-RF CD <code>(xmlidptplus.tax_tag_rf_cd_*, 26 tags; the codes are the official AT guia-de-pagamento codes — 102 trabalho independente, 104 prediais, 2xx IRC… — all still officially current, so nothing was ever announced as retired).At 16.0 the vendor rebuilds the whole RF system: dedicated withholding TAXES appear (
account_tax_template_rfirs_*/rfirc_*), and from 17.0 the template CSV carries the guide code as fields on the tax (l10n_pt_wh_tax_type/l10n_pt_wh_code/l10n_pt_wh_income_type). The vendor does migrate the other tag families —migrations/16.0.5.1.0and.5.1.2processRF DM / M10 / M30 / ISby name filter withreplace_tags()/delete_tags(), clearing the FK before the tag goes. But no filter matchesPT-RF CDand the family is re-declared under no other xmlid: dropped with no data migration (confirmed: 26 in the 15.0 data, 0 anywhere in 16.0–19.0; the vendor publishes no changelog or release notes — this PR's script is, in effect, the vendor's missing migration).Fix — selective retirement
In ptplus's own
pre-migration(runs before the global_process_end):ir_model_datapointer is moved to a retired namespace (__ptplus_legacy__,noupdate=true) instead of deleted: the record, every m2m link and the full original identity survive (account.account.taghas no note/comment field, so the renamed pointer itself is the provenance — visible as External ID in dev mode, queryable forever). No real module ever carries that name, so the collector never processes it."Referenced" = row existence in every table holding a FK to
account_account_tag, discovered dynamically from the catalog — not "the delete would fail". The distinction matters: m2m rel tables withON DELETE CASCADEwould let the GC delete a tag "successfully" while silently stripping the classification off history; existence-based selection is immune.A remap onto the new structure is deliberately not attempted: the replacement is a field on per-rate taxes (one code → many taxes), there is no tag-shaped target, and nothing at 16+ reads the CD tags (zero references in data/migrations through 19.0; no
account.tax.reportline ever pointed at them, verified on a real database with pre-16 history).This replaces a data-side SQL surrogate that previously lived in the client kit's
versions/16/hop/post.sql, moving the fix to the correct layer (the module's migration) and, crucially, before_process_endinstead of after it.Scope: local-only (proprietary vendor module; not an OCA candidate). Candidate for reporting upstream to Exo Software — any ptplus customer with pre-16 withholding history hits this on the 15→16 upgrade.