[19.0][FIX] base: populate default_user_group.implied_ids before dele…#5601
Open
GladistoneSouza wants to merge 1 commit intoOCA:19.0from
Open
[19.0][FIX] base: populate default_user_group.implied_ids before dele…#5601GladistoneSouza wants to merge 1 commit intoOCA:19.0from
GladistoneSouza wants to merge 1 commit intoOCA:19.0from
Conversation
…ting default_user
`_init_default_user_group` reads `default_user.group_ids` and writes them
into `default_user_group.implied_ids`. With the previous ordering,
`delete_records_safely_by_xml_id` removed `base.default_user` first, so
`env.ref('base.default_user', raise_if_not_found=False)` returned `None`
inside `_init_default_user_group` and the function short-circuited via its
`if not default_user: return` guard. The new `default_user_group` ended up
with an empty `implied_ids`, and users created post-migration did not
inherit the default group set.
Moving `_init_default_user_group(env)` to run before the delete fixes the
transfer.
Verified on two real Odoo 18 production backups (2026-04-21 and
2026-04-24): without the patch `default_user_group.implied_ids` is 0; with
the patch it matches the source `default_user.group_ids` count (37 in both
cases). Reverting the patch against the same database reproduces the zero
state — A/B/A/B confirmed.
Signed-off-by: Gladistone Souza <gladistone09@gmail.com>
hbrunn
requested changes
Apr 24, 2026
Comment on lines
+102
to
+105
| # _init_default_user_group must run BEFORE deleting base.default_user, | ||
| # because it reads default_user.group_ids to populate | ||
| # default_user_group.implied_ids. Running it after the delete leaves | ||
| # the new group with an empty implied_ids set. |
Member
There was a problem hiding this comment.
the commit message is verbose enough, so this seems overkill to me. good catch though
remi-filament
approved these changes
Apr 25, 2026
Contributor
There was a problem hiding this comment.
Thanks @GladistoneSouza
The description is quite long and seems generated by IA, the fix is indeed needed !
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.
Summary
_init_default_user_groupinopenupgrade_scripts/scripts/base/19.0.1.3/post-migration.pyis invoked afterdelete_records_safely_by_xml_id(['base.default_user', ...]). Because it short-circuits whenbase.default_userno longer resolves, the migration always produces abase.default_user_groupwith an emptyimplied_idsset — so userscreated after a migration stop inheriting the default group set that the deleted
base.default_usercarried.Moving
_init_default_user_group(env)to run before the delete fixes the transfer.Root cause
The helper starts with:
The current
migrate()calls the deletion before the transfer:After the delete,
env.ref("base.default_user", raise_if_not_found=False)returnsNone,_init_default_user_grouphits itsif not default_user: returnguard, and theimplied_idswrite never happens. The newbase.default_user_groupremains empty.Fix
Swap the order: populate the new group while the old user still exists, then delete.
Diff:
+5 / -1(the_init_default_user_groupcall moves; a short comment is added explaining the ordering constraint). No change to_init_default_user_groupitself or to any other helper.Impact
With the ordering bug in place, every 18 → 19 migration silently loses the default group set for future user creations. Existing users are unaffected — their explicit group memberships are preserved — but newly created users no longer receive the defaults automatically, which is the exact behavior
base.default_user_groupwas introduced to provide.Evidence
Validated against two real Odoo 18 production backups by running the full upgrade pipeline four times, flipping only this two-line ordering:
default_user_group.implied_idsdefault_user.group_idson Odoo 18A/B/A/B on the same database confirms the behavior is deterministic and tied solely to this call ordering. Source
group_idscount (37) is preserved end-to-end only when the patch is applied.Checklist
migrate()changes;_init_default_user_groupitself is untouched.