Skip to content

[19.0][FIX] base: rename user.groups_id references in domain/code#1

Open
dnplkndll wants to merge 2 commits into
ledoentfrom
19.0-fix-user-groups-id-rename
Open

[19.0][FIX] base: rename user.groups_id references in domain/code#1
dnplkndll wants to merge 2 commits into
ledoentfrom
19.0-fix-user-groups-id-rename

Conversation

@dnplkndll
Copy link
Copy Markdown

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 on res_users and quoted occurrences in ir.filters.domain, but it does NOT process:

  • ir.rule.domain_force — not touched at all
  • Unquoted dotted references like user.groups_id.ids that appear inside Python-evaluated domain expressions / server-action code

Concretely, an ir.rule such as:

domain_force = "[('groups_id', 'in', user.groups_id.ids)]"

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:

AttributeError: 'res.users' object has no attribute 'groups_id'

(groups_id was renamed to group_ids in Odoo 19; Odoo core then promotes user.group_ids to user.all_group_ids for the implied-groups check, but the source groups_id reference has to be rewritten first.)

Fix

Add a post-step in base/19.0.1.3/pre-migration.py that does a word-boundary regex replace of user.groups_iduser.group_ids in:

  • ir_rule.domain_force
  • ir_filters.domain
  • ir_act_server.code

How tested

Migrated a real Ledo Enterprises prod 18.0 backup (168 installed modules) to 19.0:

  1. 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 was ir.rule#345 "Website menu: group_ids".

  2. With the fix — re-restored prod backup, manually set ir.rule#345.domain_force back to the broken user.groups_id form 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 to user.group_ids, and Odoo core then upgraded it further to the canonical user.all_group_ids.

  3. Migration also exercised: ir_filters and ir_act_server queries; no false matches in the test corpus.

Test plan

  • Migration completes without AttributeError on res.users.groups_id
  • ir.rule.domain_force containing user.groups_id.ids is rewritten
  • Login page renders (HTTP 200) after migration
  • Promote to OCA/OpenUpgrade once additional review here is done

Branch: 19.0-fix-user-groups-id-rename
Tracking lab: ledoent/openupgrade-labscripts/restore-prod.sh carries an SQL fallback for unpatched OpenUpgrade copies.

dnplkndll added 2 commits May 13, 2026 18:00
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.
@dnplkndll dnplkndll force-pushed the 19.0-fix-user-groups-id-rename branch from 9559616 to 08c7b52 Compare May 13, 2026 22:01
@dnplkndll dnplkndll changed the base branch from 19.0 to ledoent May 13, 2026 22:01
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