[19.0][FIX] base: rename user.groups_id references in domain/code#1
Open
dnplkndll wants to merge 2 commits into
Open
[19.0][FIX] base: rename user.groups_id references in domain/code#1dnplkndll wants to merge 2 commits into
dnplkndll wants to merge 2 commits into
Conversation
The test-migration workflow uses ${{github.repository}}/releases/download/databases
to fetch the 18.0.psql test fixture, which means forks have to mirror
the multi-GB DB dumps from OCA into their own releases just to run CI.
Pin the download URL to OCA/OpenUpgrade's releases regardless of where
the workflow runs. Forks can keep using the OCA-provided fixtures and
contributions can be tested without preparation.
`rename_fields()` (via `rename_field_references` in openupgradelib)
renames the field column and quoted occurrences in ir.filters.domain,
but it doesn't process:
* ir.rule.domain_force (not touched at all)
* unquoted dotted references like `user.groups_id.ids` in Python
expressions inside domain_force / ir.filters.domain / ir.act_server.code
Concretely, an ir.rule with
domain_force = "[('groups_id', 'in', user.groups_id.ids)]"
has its LHS migrated to `'group_ids'` but the RHS is left untouched,
which then crashes any view that triggers the rule with
AttributeError: 'res.users' object has no attribute 'groups_id'
Add a post-step in base/19.0.1.3 pre-migration that does a word-boundary
regex_replace of `user.groups_id` → `user.group_ids` in:
* ir_rule.domain_force
* ir_filters.domain
* ir_act_server.code
Reproduced migrating a real prod 18.0 database (Ledo Enterprises) to
19.0: the login page returned HTTP 500 with the AttributeError until
the ir.rule for `Website menu: group_ids` was patched manually.
9559616 to
08c7b52
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.
Context
This is an internal fork PR for testing before submitting upstream to OCA/OpenUpgrade. See OCA/OpenUpgrade#5363 for the 19.0 migration umbrella.
Problem
rename_fields()(from openupgradelib) renames the column onres_usersand quoted occurrences inir.filters.domain, but it does NOT process:ir.rule.domain_force— not touched at alluser.groups_id.idsthat appear inside Python-evaluated domain expressions / server-action codeConcretely, an
ir.rulesuch as:has its LHS migrated to
'group_ids'but the RHS is left untouched. After migration, any view that triggers the rule crashes at runtime with:(
groups_idwas renamed togroup_idsin Odoo 19; Odoo core then promotesuser.group_idstouser.all_group_idsfor the implied-groups check, but the sourcegroups_idreference has to be rewritten first.)Fix
Add a post-step in
base/19.0.1.3/pre-migration.pythat does a word-boundary regex replace ofuser.groups_id→user.group_idsin:ir_rule.domain_forceir_filters.domainir_act_server.codeHow tested
Migrated a real Ledo Enterprises prod 18.0 backup (168 installed modules) to 19.0:
Without the fix — login page returned HTTP 500:
AttributeError("'res.users' object has no attribute 'groups_id'") while evaluating "['|', ('group_ids', '=', False), ('group_ids', 'in', user.groups_id.ids)]". The offending record wasir.rule#345"Website menu: group_ids".With the fix — re-restored prod backup, manually set
ir.rule#345.domain_forceback to the brokenuser.groups_idform to simulate a stock-restore scenario, then ran the migration. The pre-migration's regex_replace fired (visible in logs), the ir.rule was rewritten touser.group_ids, and Odoo core then upgraded it further to the canonicaluser.all_group_ids.Migration also exercised:
ir_filtersandir_act_serverqueries; no false matches in the test corpus.Test plan
AttributeErroronres.users.groups_idir.rule.domain_forcecontaininguser.groups_id.idsis rewrittenBranch: 19.0-fix-user-groups-id-rename
Tracking lab: ledoent/openupgrade-lab —
scripts/restore-prod.shcarries an SQL fallback for unpatched OpenUpgrade copies.