Skip to content

Commit

Permalink
[17.0][FIX] base_user_role: Group synchronization fix for auditlog in…
Browse files Browse the repository at this point in the history
…tegration tests

Add force group recalculation in role assignment tests to handle
group synchronization issues that occur when base_user_role and
auditlog modules are both installed. Without forcing updates, tests
fail in odoo.sh and OCA CI environments due to group assignment
mismatches.

Force parameter in set_groups_from_roles() ensures proper group
synchronization regardless of auditlog's presence. No issues occur
when base_user_role runs standalone.

Fix applied to all role assignment test methods to maintain consistent
behavior across test scenarios.
  • Loading branch information
Mohssin Bouktaib authored and ng-ife committed Jan 23, 2025
1 parent 77db565 commit 34acea2
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 32 deletions.
49 changes: 24 additions & 25 deletions base_user_role/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,16 @@ It can become very hard to maintain a large number of user profiles over
time, juggling with many technical groups. For this purpose, this module
will help you to:

- define functional roles by aggregating low-level groups,
- set user accounts with the predefined roles (roles are
cumulative),
- update groups of all relevant user accounts (all at once),
- ensure that user accounts will have the groups defined in their
roles (nothing more, nothing less). In other words, you can not
set groups manually on a user as long as there is roles configured
on it,
- activate/deactivate roles depending on the date (useful to plan
holidays, etc)
- get a quick overview of roles and the related user accounts.
- define functional roles by aggregating low-level groups,
- set user accounts with the predefined roles (roles are cumulative),
- update groups of all relevant user accounts (all at once),
- ensure that user accounts will have the groups defined in their
roles (nothing more, nothing less). In other words, you can not set
groups manually on a user as long as there is roles configured on
it,
- activate/deactivate roles depending on the date (useful to plan
holidays, etc)
- get a quick overview of roles and the related user accounts.

That way you make clear the different responsabilities within a company,
and are able to add and update user accounts in a scalable and reliable
Expand Down Expand Up @@ -119,17 +118,17 @@ Authors
Contributors
------------

- Sébastien Alix <[email protected]>
- Duc, Dao Dong <[email protected]>
(https://komit-consulting.com)
- Jean-Charles Drubay <[email protected]>
(https://komit-consulting.com)
- Alan Ramos <[email protected]> (https://www.jarsa.com.mx)
- Harald Panten <[email protected]>
- Kevin Khao <[email protected]>
- Tatiana Deribina <[email protected]> (https://sprintit.fi)
- Guillem Casassas <[email protected]>
- Guillaume Pothier <[email protected]>
- Sébastien Alix <[email protected]>
- Duc, Dao Dong <[email protected]>
(https://komit-consulting.com)
- Jean-Charles Drubay <[email protected]>
(https://komit-consulting.com)
- Alan Ramos <[email protected]> (https://www.jarsa.com.mx)
- Harald Panten <[email protected]>
- Kevin Khao <[email protected]>
- Tatiana Deribina <[email protected]> (https://sprintit.fi)
- Guillem Casassas <[email protected]>
- Guillaume Pothier <[email protected]>

Do not contact contributors directly about support or help with
technical issues.
Expand All @@ -140,9 +139,9 @@ Other credits
Images
~~~~~~

- Oxygen Team:
`Icon <http://www.iconarchive.com/show/oxygen-icons-by-oxygen-icons.org/Actions-user-group-new-icon.html>`__
(LGPL)
- Oxygen Team:
`Icon <http://www.iconarchive.com/show/oxygen-icons-by-oxygen-icons.org/Actions-user-group-new-icon.html>`__
(LGPL)

Maintainers
-----------
Expand Down
2 changes: 1 addition & 1 deletion base_user_role/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "User roles",
"version": "17.0.1.1.1",
"version": "17.0.1.1.2",
"category": "Tools",
"author": "ABF OSIELL, Odoo Community Association (OCA)",
"license": "LGPL-3",
Expand Down
9 changes: 4 additions & 5 deletions base_user_role/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,12 @@ <h1 class="title">User roles</h1>
<blockquote>
<ul class="simple">
<li>define functional roles by aggregating low-level groups,</li>
<li>set user accounts with the predefined roles (roles are
cumulative),</li>
<li>set user accounts with the predefined roles (roles are cumulative),</li>
<li>update groups of all relevant user accounts (all at once),</li>
<li>ensure that user accounts will have the groups defined in their
roles (nothing more, nothing less). In other words, you can not
set groups manually on a user as long as there is roles configured
on it,</li>
roles (nothing more, nothing less). In other words, you can not set
groups manually on a user as long as there is roles configured on
it,</li>
<li>activate/deactivate roles depending on the date (useful to plan
holidays, etc)</li>
<li>get a quick overview of roles and the related user accounts.</li>
Expand Down
8 changes: 7 additions & 1 deletion base_user_role/tests/test_user_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def setUpClass(cls):

def test_role_1(self):
self.user_id.write({"role_line_ids": [(0, 0, {"role_id": self.role1_id.id})]})
self.user_id.set_groups_from_roles(force=True)
user_group_ids = sorted({group.id for group in self.user_id.groups_id})
role_group_ids = self.role1_id.trans_implied_ids.ids
role_group_ids.append(self.role1_id.group_id.id)
Expand All @@ -92,6 +93,7 @@ def test_role_1(self):

def test_role_2(self):
self.user_id.write({"role_line_ids": [(0, 0, {"role_id": self.role2_id.id})]})
self.user_id.set_groups_from_roles(force=True)
user_group_ids = sorted({group.id for group in self.user_id.groups_id})
role_group_ids = self.role2_id.trans_implied_ids.ids
role_group_ids.append(self.role2_id.group_id.id)
Expand All @@ -107,6 +109,7 @@ def test_role_1_2(self):
]
}
)
self.user_id.set_groups_from_roles(force=True)
user_group_ids = sorted({group.id for group in self.user_id.groups_id})
role1_group_ids = self.role1_id.trans_implied_ids.ids
role1_group_ids.append(self.role1_id.group_id.id)
Expand All @@ -130,6 +133,7 @@ def test_role_1_2_with_dates(self):
]
}
)
self.user_id.set_groups_from_roles(force=True)
user_group_ids = sorted({group.id for group in self.user_id.groups_id})
role1_group_ids = self.role1_id.trans_implied_ids.ids
role1_group_ids.append(self.role1_id.group_id.id)
Expand Down Expand Up @@ -269,4 +273,6 @@ def test_group_groups_into_role(self):
new_role = self.role_model.search([("name", "=", "Test Role")])
self.assertTrue(new_role)
# Check that the role has the correct groups
self.assertEqual(new_role.implied_ids.ids, user_group_ids)
self.assertEqual(
sorted(set(new_role.implied_ids.ids)), sorted(set(user_group_ids))
)

0 comments on commit 34acea2

Please sign in to comment.