Skip to content

fix(spp_user_roles): exclude role-backing groups from Groups dropdown#159

Open
emjay0921 wants to merge 3 commits into19.0from
fix/role-groups-dropdown-filter
Open

fix(spp_user_roles): exclude role-backing groups from Groups dropdown#159
emjay0921 wants to merge 3 commits into19.0from
fix/role-groups-dropdown-filter

Conversation

@emjay0921
Copy link
Copy Markdown
Contributor

Why is this change needed?

When creating a role via the UI (Settings → Users & Companies → User Roles → New), Odoo 19 auto-creates a backing res.groups record. These role-backing groups then appear in the Groups tab dropdown of other roles alongside legitimate permission groups, causing confusion.

How was the change implemented?

Added a domain filter [('role_id', '=', False)] on the implied_ids field in the role form view. This excludes any res.groups record that has a linked res.users.role — i.e., role-backing groups are hidden from the dropdown while standard permission groups remain visible.

New unit tests

N/A — view-only change.

Unit tests executed by the author

Existing spp_user_roles tests pass.

How to test manually

  1. Go to Settings → Users & Companies → User Roles
  2. Create a new role (e.g., "Test Role") — this auto-creates a backing group
  3. Open any other role (e.g., "Local Support")
  4. Go to the Groups tab and search — "Test Role" should NOT appear in the dropdown
  5. Module-defined groups (e.g., "HDX User / HDX User") should still appear

Related links

https://projects.acn.fr/projects/acn-eng/work_packages/888

UI-created roles auto-generate backing res.groups records that then
appear in the Groups tab dropdown of other roles. Add domain filter
on implied_ids to exclude groups linked to roles.
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 modifies the role view in Odoo to apply a domain filter on the implied_ids field. A critical issue was identified regarding the use of the role_id field in the domain, as it is not a standard Odoo field and is missing from the provided model definitions. This would likely cause a traceback, so it is recommended to define the inverse field on the res.groups model as suggested.

Comment on lines +23 to +27
<xpath expr="//field[@name='implied_ids']" position="attributes">
<attribute
name="domain"
>[('role_id', '=', False)]</attribute>
</xpath>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The domain [('role_id', '=', False)] refers to a field role_id on the res.groups model. This field is not a standard Odoo field, nor is it defined in the base_user_role module or the provided spp_user_roles/models/role.py file.

Unless this field is defined in a dependency not shown in this PR, this will cause a traceback when loading the form view. To fix this, you should define the inverse field in your Python models (e.g., in spp_user_roles/models/role.py):

class ResGroups(models.Model):
    _inherit = "res.groups"

    role_id = fields.One2many(
        comodel_name="res.users.role",
        inverse_name="group_id",
        string="Associated Role",
    )
            <xpath expr="//field[@name='implied_ids']" position="attributes">
                <attribute name="domain">[('role_id', '=', False)]</attribute>
            </xpath>

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.33%. Comparing base (aaa9001) to head (1e5d802).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             19.0     #159   +/-   ##
=======================================
  Coverage   71.33%   71.33%           
=======================================
  Files         932      932           
  Lines       54975    54975           
=======================================
  Hits        39217    39217           
  Misses      15758    15758           
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 79.26% <ø> (ø)
spp_area_hdx 81.43% <ø> (ø)
spp_audit 72.60% <ø> (ø)
spp_base_common 90.26% <ø> (ø)
spp_case_cel 89.01% <ø> (ø)
spp_case_demo 94.34% <ø> (ø)
spp_programs 62.23% <ø> (ø)
spp_security 66.66% <ø> (ø)

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

🚀 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.

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