Skip to content

fix(spp_user_roles): remove _default_role_lines that copies roles from arbitrary users#163

Open
gonzalesedwin1123 wants to merge 1 commit into19.0from
fix/default-role-lines-arbitrary-user
Open

fix(spp_user_roles): remove _default_role_lines that copies roles from arbitrary users#163
gonzalesedwin1123 wants to merge 1 commit into19.0from
fix/default-role-lines-arbitrary-user

Conversation

@gonzalesedwin1123
Copy link
Copy Markdown
Member

Summary

Closes #156

  • Remove the buggy _default_role_lines() override from spp_user_roles that copied roles from an arbitrary user to all newly created users (the base.default_user XMLID was removed in Odoo 19, so the fallback always fired)
  • Remove the dead _default_role_lines() override from spp_area that enriched defaults with area data from base.default_user (was a no-op since Odoo 19)
  • The upstream base_user_role OCA module already provides the correct mechanism via an is_default boolean on res.users.role — admins can mark specific roles to be auto-assigned to new users
  • Rewrite test to verify the is_default mechanism instead of the old buggy behavior
  • Fix pre-existing tuple syntax (0, 0, {...})Command.create() per Odoo 19 conventions

Test plan

  • spp_user_roles — 3/3 pass
  • spp_area — 50/50 pass
  • spp_approval — 128/128 pass (creates users, depends indirectly on role system)
  • spp_programs — 579/579 pass (depends on spp_user_roles)
  • Lint clean (ruff, ruff-format)
  • Expert review: code reviewer, UX expert, module verification — no critical issues

…roles from arbitrary users

The override tried base.default_user (removed in Odoo 19) then fell back
to copying roles from the first user with any role lines — silently
giving every new user an arbitrary set of roles. The upstream base_user_role
OCA module already handles this correctly via an is_default boolean on
res.users.role. Remove the dead overrides from spp_user_roles and spp_area,
rewrite the test to verify the is_default mechanism, and fix tuple syntax
to use Command.create() per Odoo 19 conventions.

Closes #156
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.21%. Comparing base (5a7544e) to head (5a5542f).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             19.0     #163      +/-   ##
==========================================
+ Coverage   71.19%   71.21%   +0.01%     
==========================================
  Files         931      931              
  Lines       54694    54685       -9     
==========================================
  Hits        38942    38942              
+ Misses      15752    15743       -9     
Flag Coverage Δ
spp_analytics 93.13% <ø> (ø)
spp_api_v2 80.10% <ø> (ø)
spp_api_v2_change_request 66.85% <ø> (ø)
spp_api_v2_cycles 71.12% <ø> (ø)
spp_api_v2_data 64.41% <ø> (ø)
spp_api_v2_entitlements 70.19% <ø> (ø)
spp_api_v2_gis 71.52% <ø> (ø)
spp_api_v2_products 66.27% <ø> (ø)
spp_api_v2_service_points 70.94% <ø> (ø)
spp_api_v2_simulation 71.12% <ø> (ø)
spp_api_v2_vocabulary 57.26% <ø> (ø)
spp_approval 50.29% <ø> (ø)
spp_area 80.07% <ø> (+0.80%) ⬆️
spp_area_hdx 81.43% <ø> (ø)
spp_audit 72.60% <ø> (+0.06%) ⬆️
spp_base_common 90.26% <ø> (ø)
spp_case_cel 89.01% <ø> (ø)
spp_case_demo 94.34% <ø> (ø)
spp_programs 62.17% <ø> (ø)
spp_security 66.66% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
spp_area/models/user.py 56.25% <ø> (+15.50%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the _default_role_lines method from the user models in spp_area and spp_user_roles. The logic for assigning default roles has been shifted, and the test suite has been updated to verify that default roles are now determined by an is_default flag on the roles themselves rather than being inherited from a template user. Additionally, the tests were refactored to use the Command helper for record creation. I have no feedback to provide.

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.

_default_role_lines() copies roles from arbitrary users to all new users on Odoo 19

2 participants