From 6217a00b166e30a15d9f53b1167cf17f8f38f578 Mon Sep 17 00:00:00 2001 From: Mark Penalosa Date: Thu, 30 Apr 2026 09:45:22 +0800 Subject: [PATCH 1/5] fix(spp_user_roles): prevent validation error when assigning groups to a new role --- spp_user_roles/models/role.py | 25 ++++++++++++++++++++++++- spp_user_roles/views/role.xml | 13 ++++++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/spp_user_roles/models/role.py b/spp_user_roles/models/role.py index 069a2b09..c6e83d7b 100644 --- a/spp_user_roles/models/role.py +++ b/spp_user_roles/models/role.py @@ -2,7 +2,7 @@ import logging -from odoo import fields, models +from odoo import api, fields, models _logger = logging.getLogger(__name__) @@ -12,6 +12,29 @@ class ResUsersRoleCustomSPP(models.Model): role_type = fields.Selection([("local", "Local"), ("global", "Global")], default="global") + @api.model_create_multi + def create(self, vals_list): + # Workaround: same Odoo cache-clearing bug as in base_user_role's write() + # override. When res.groups fields are set via _inherits on create(), + # implied_ids gets dropped. Extract group fields and write them to + # group_id directly after creation, mirroring the write() fix. + groups_vals_list = [] + group_fields = set(self.env["res.groups"]._fields) - {"name"} + for vals in vals_list: + group_vals = {} + for field in group_fields: + if field in vals: + group_vals[field] = vals.pop(field) + groups_vals_list.append(group_vals) + + new_records = super().create(vals_list) + + for record, group_vals in zip(new_records, groups_vals_list): + if group_vals: + record.group_id.write(group_vals) + + return new_records + def action_update_users(self): """ Call the update_users function to force the update of associated users in the role. diff --git a/spp_user_roles/views/role.xml b/spp_user_roles/views/role.xml index 0637e402..c15f029f 100644 --- a/spp_user_roles/views/role.xml +++ b/spp_user_roles/views/role.xml @@ -20,9 +20,16 @@ - - [('role_id', '=', False)] - many2many + + + + + + Date: Mon, 4 May 2026 11:16:29 +0800 Subject: [PATCH 2/5] fix(spp_user_roles): pass strict=True to zip() in create override MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI's ruff (B905) flagged `zip(new_records, groups_vals_list)` for omitting the explicit `strict=` parameter. The two iterables are built side-by-side in the same loop above the call, so they're guaranteed equal length — make it explicit with `strict=True` to satisfy the linter and turn an undetectable mismatch into a clear runtime error if the invariant ever breaks. --- spp_user_roles/models/role.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spp_user_roles/models/role.py b/spp_user_roles/models/role.py index c6e83d7b..472eee14 100644 --- a/spp_user_roles/models/role.py +++ b/spp_user_roles/models/role.py @@ -29,7 +29,7 @@ def create(self, vals_list): new_records = super().create(vals_list) - for record, group_vals in zip(new_records, groups_vals_list): + for record, group_vals in zip(new_records, groups_vals_list, strict=True): if group_vals: record.group_id.write(group_vals) From 980b34f04f948187fbd201f946e4e0896ea26119 Mon Sep 17 00:00:00 2001 From: emjay0921 Date: Mon, 4 May 2026 11:28:16 +0800 Subject: [PATCH 3/5] fix(spp_user_roles): drop position=replace on implied_ids MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit OCA xml-view-dangerous-replace-low-priority hook flagged the position="replace" used to add a domain and an embedded list to the `implied_ids` field on the role form. Replace is reserved as a last resort; the same effect can be achieved with position="attributes" (for the new domain) plus position="inside" (to embed the list). Functionally identical for OP#979 — the field still restricts the group dropdown to free groups and the inline list still has create disabled, but the inheritance is now safer for downstream views. --- spp_user_roles/views/role.xml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/spp_user_roles/views/role.xml b/spp_user_roles/views/role.xml index c15f029f..1817878b 100644 --- a/spp_user_roles/views/role.xml +++ b/spp_user_roles/views/role.xml @@ -20,16 +20,19 @@ - - - - - - + + + [('role_id', '=', False)] + + + + + Date: Mon, 11 May 2026 10:46:21 +0800 Subject: [PATCH 4/5] =?UTF-8?q?chore(spp=5Fuser=5Froles):=20bump=2019.0.2.?= =?UTF-8?q?0.0=20=E2=86=92=2019.0.2.0.1=20+=20HISTORY=20entry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spp_user_roles/__manifest__.py | 2 +- spp_user_roles/readme/HISTORY.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/spp_user_roles/__manifest__.py b/spp_user_roles/__manifest__.py index 45f4ded4..839997cf 100644 --- a/spp_user_roles/__manifest__.py +++ b/spp_user_roles/__manifest__.py @@ -2,7 +2,7 @@ { "name": "OpenSPP User Roles", "category": "OpenSPP", - "version": "19.0.2.0.0", + "version": "19.0.2.0.1", "sequence": 1, "author": "OpenSPP.org", "website": "https://github.com/OpenSPP/OpenSPP2", diff --git a/spp_user_roles/readme/HISTORY.md b/spp_user_roles/readme/HISTORY.md index 4aaf9afe..32ad2824 100644 --- a/spp_user_roles/readme/HISTORY.md +++ b/spp_user_roles/readme/HISTORY.md @@ -1,3 +1,7 @@ +### 19.0.2.0.1 + +- fix(role): allow assigning groups to a brand-new role in a single save. Clicking **Add a line** in the role form's Groups tab used to trigger inline creation of a blank `res.groups` row, which raised a required-field validation error and aborted the save. The `implied_ids` field's inner list now uses `create="0"` so the button opens an "Add" picker against existing groups, and `res.users.role.create()` extracts `implied_ids` before `super().create()` and writes them to the role's `group_id` afterwards — mirroring the existing `write()` workaround in `base_user_role` for the same `_inherits` cache-clearing bug. + ### 19.0.2.0.0 - Initial migration to OpenSPP2 From ead65fffdf18502e987284b8d64c7cf1e1f0096e Mon Sep 17 00:00:00 2001 From: emjay0921 Date: Mon, 11 May 2026 10:57:11 +0800 Subject: [PATCH 5/5] chore(spp_user_roles): regenerate README to match CI docutils output --- spp_user_roles/README.rst | 14 ++++++++++++++ spp_user_roles/static/description/index.html | 15 +++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/spp_user_roles/README.rst b/spp_user_roles/README.rst index fc888a65..dd1b3257 100644 --- a/spp_user_roles/README.rst +++ b/spp_user_roles/README.rst @@ -129,6 +129,20 @@ Dependencies Changelog ========= +19.0.2.0.1 +~~~~~~~~~~ + +- fix(role): allow assigning groups to a brand-new role in a single + save. Clicking **Add a line** in the role form's Groups tab used to + trigger inline creation of a blank ``res.groups`` row, which raised a + required-field validation error and aborted the save. The + ``implied_ids`` field's inner list now uses ``create="0"`` so the + button opens an "Add" picker against existing groups, and + ``res.users.role.create()`` extracts ``implied_ids`` before + ``super().create()`` and writes them to the role's ``group_id`` + afterwards — mirroring the existing ``write()`` workaround in + ``base_user_role`` for the same ``_inherits`` cache-clearing bug. + 19.0.2.0.0 ~~~~~~~~~~ diff --git a/spp_user_roles/static/description/index.html b/spp_user_roles/static/description/index.html index 432698ea..68f7ea2e 100644 --- a/spp_user_roles/static/description/index.html +++ b/spp_user_roles/static/description/index.html @@ -503,6 +503,21 @@

Changelog

+

19.0.2.0.1

+
    +
  • fix(role): allow assigning groups to a brand-new role in a single +save. Clicking Add a line in the role form’s Groups tab used to +trigger inline creation of a blank res.groups row, which raised a +required-field validation error and aborted the save. The +implied_ids field’s inner list now uses create="0" so the +button opens an “Add” picker against existing groups, and +res.users.role.create() extracts implied_ids before +super().create() and writes them to the role’s group_id +afterwards — mirroring the existing write() workaround in +base_user_role for the same _inherits cache-clearing bug.
  • +
+
+

19.0.2.0.0

  • Initial migration to OpenSPP2