Skip to content

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

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

[FIX] base: rename user.groups_id references in domain/code#1
dnplkndll wants to merge 63 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 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
@dnplkndll dnplkndll force-pushed the ledoent branch 2 times, most recently from 17bc71e to a67dc15 Compare May 18, 2026 15:58
@dnplkndll dnplkndll force-pushed the 19.0-fix-user-groups-id-rename branch from 08c7b52 to 459d5e6 Compare May 19, 2026 13:59
@dnplkndll dnplkndll changed the title [19.0][FIX] base: rename user.groups_id references in domain/code [FIX] base: rename user.groups_id references in domain/code May 19, 2026
@dnplkndll dnplkndll force-pushed the 19.0-fix-user-groups-id-rename branch from 459d5e6 to 76480c6 Compare May 30, 2026 03:47
@dnplkndll dnplkndll force-pushed the 19.0-fix-user-groups-id-rename branch from 76480c6 to 144184c Compare June 3, 2026 18:43
@dnplkndll dnplkndll force-pushed the 19.0-fix-user-groups-id-rename branch from 144184c to 7eb12cd Compare June 5, 2026 19:53
@dnplkndll dnplkndll force-pushed the 19.0-fix-user-groups-id-rename branch 2 times, most recently from d6a6be8 to 3d7e153 Compare June 17, 2026 12:45
mvalee and others added 2 commits June 17, 2026 20:52
@dnplkndll dnplkndll force-pushed the 19.0-fix-user-groups-id-rename branch from 3d7e153 to 5285643 Compare June 19, 2026 11:58
pedrobaeza and others added 29 commits June 30, 2026 09:43
[19.0][OU-ADD] maintenance,stock_maintenance: Migration scripts
[19.0][OU-ADD] hr_maintenance: Nothing to do
[19.0][OU-ADD] survey: Migration scripts
[19.0][OU-ADD] website_profile: Migration scripts
Signed-off-by hbrunn
when dependencies are added in same PR
[19.0][IMP] check_dependency: don't set blocked label when dependencies are added in same PR
…nstile

[19.0][OU-ADD] website_cf_turnstile: Nothing to do
[19.0][OU-ADD] event_product: Migration scripts
[19.0][OU-ADD] payment_stripe: Nothing to do
[19.0][OU-ADD] l10n_fr: Migration scripts
[19.0][OU-ADD] l10n_fr_account: Nothing to do
[19.0][OU-ADD] microsoft_outlook: Nothing to do
[19.0][OU-ADD] mail_bot_hr: Nothing to do
18's stored groups_id was the transitive group set; rewriting to
group_ids (explicit only) silently narrowed membership tests in custom
rules/filters/server actions. Map to all_group_ids (as 19 core did for
its own rule data) and also rewrite the quoted LHS of res.users-scoped
domains, which rename_field_references never touches.
…="Group By")

Folds in the previously-stranded 19.0-fix-base-strip-search-view-removed-attrs
work onto the base-owning branch (one folder = one branch). 19.0's stricter
RelaxNG schema rejects `expand=` on <group>/<field> and `string="Group By"`
on <group>; stored 18.0 search-view arch_db carrying them crashes view
validation on first load. Strips them from ir_ui_view.arch_db (jsonb-aware,
per-lang) in base pre-migration. Tests cover both <group expand=>/<field
expand=> stripping and legitimate-attr preservation.
@dnplkndll dnplkndll force-pushed the 19.0-fix-user-groups-id-rename branch from f60365a to 70f6429 Compare July 8, 2026 20:24
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.

10 participants