Describe the bug
_default_role_lines() in spp_user_roles/models/user.py copies role lines from an arbitrary user to every newly created user when base.default_user is missing (which is always the case in Odoo 19, since that XMLID was removed).
The fallback at line 36 picks the first user in the database that has any role lines:
if not default_user:
default_user = self.env["res.users"].search([("role_line_ids", "!=", False)], limit=1)
This can match service accounts, API users, or any non-human user. Once matched, every new user inherits that user's roles, which triggers set_groups_from_roles() and silently overwrites any group_ids passed in the create() call.
To Reproduce
- Install
spp_user_roles on Odoo 19 (where base.default_user does not exist)
- Create any user with a role line (e.g. a service account, or any user assigned a global role)
- Create a new user with explicit
group_ids but without specifying role_line_ids
- Observe that the new user has inherited the role from step 2, and the
group_ids passed in step 3 have been replaced by the role's implied groups
Expected behavior
- New users should not inherit role lines from unrelated users
group_ids passed during create() should be respected
- If no default user template exists,
_default_role_lines() should return an empty list rather than picking an arbitrary user
Screenshots
N/A
Additional context
base.default_user was removed in Odoo 19, so the fallback search fires on every installation — this is not an edge case
- The search has no filtering: it can pick up service accounts, system users, or the admin — whichever has the lowest ID and has role lines
- The inherited role triggers
set_groups_from_roles() during user creation, which silently replaces any directly assigned groups with the role's implied groups
- This also breaks test suites: any test that creates users with specific
group_ids will fail once any user in the database has a role line
- Current workaround: pass
role_line_ids=[] explicitly on every res.users.create() call to suppress the default
🔔 Note: This ticket should address common considerations without including country-specific content. Please ensure all references are generic and applicable across various contexts.
Describe the bug
_default_role_lines()inspp_user_roles/models/user.pycopies role lines from an arbitrary user to every newly created user whenbase.default_useris missing (which is always the case in Odoo 19, since that XMLID was removed).The fallback at line 36 picks the first user in the database that has any role lines:
This can match service accounts, API users, or any non-human user. Once matched, every new user inherits that user's roles, which triggers
set_groups_from_roles()and silently overwrites anygroup_idspassed in thecreate()call.To Reproduce
spp_user_roleson Odoo 19 (wherebase.default_userdoes not exist)group_idsbut without specifyingrole_line_idsgroup_idspassed in step 3 have been replaced by the role's implied groupsExpected behavior
group_idspassed duringcreate()should be respected_default_role_lines()should return an empty list rather than picking an arbitrary userScreenshots
N/A
Additional context
base.default_userwas removed in Odoo 19, so the fallback search fires on every installation — this is not an edge caseset_groups_from_roles()during user creation, which silently replaces any directly assigned groups with the role's implied groupsgroup_idswill fail once any user in the database has a role linerole_line_ids=[]explicitly on everyres.users.create()call to suppress the default🔔 Note: This ticket should address common considerations without including country-specific content. Please ensure all references are generic and applicable across various contexts.