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 committed Jan 24, 2025
1 parent 77db565 commit f23fa7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions base_user_role/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
User roles
==========

..
..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
Expand Down Expand Up @@ -169,7 +169,7 @@ promote its widespread use.

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-sebalix| |maintainer-jcdrubay| |maintainer-novawish|
|maintainer-sebalix| |maintainer-jcdrubay| |maintainer-novawish|

This module is part of the `OCA/server-backend <https://github.com/OCA/server-backend/tree/17.0/base_user_role>`_ project on GitHub.

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 f23fa7f

Please sign in to comment.