From 908bedadbac753fcf70701504757feb4b7332bc4 Mon Sep 17 00:00:00 2001 From: Mohssin Bouktaib Date: Wed, 8 Jan 2025 09:08:12 +0100 Subject: [PATCH] [17.0][FIX] base_user_role: Group synchronization fix for auditlog integration 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. --- base_user_role/tests/test_user_role.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/base_user_role/tests/test_user_role.py b/base_user_role/tests/test_user_role.py index 63444c018..372b86cee 100644 --- a/base_user_role/tests/test_user_role.py +++ b/base_user_role/tests/test_user_role.py @@ -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) @@ -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) @@ -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) @@ -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) @@ -270,7 +274,16 @@ def test_group_groups_into_role(self): ) res = wizard.create_role() # Check that a role with name: Test Role has been created +<<<<<<< HEAD new_role = self.env[res["res_model"]].browse(res["res_id"]) self.assertEqual(new_role.name, "Test Role") # Check that the role has the correct groups (even if the order is not equal) self.assertEqual(set(new_role.implied_ids.ids), set(user_group_ids)) +======= + new_role = self.role_model.search([("name", "=", "Test Role")]) + self.assertTrue(new_role) + # Check that the role has the correct groups + self.assertEqual( + sorted(set(new_role.implied_ids.ids)), sorted(set(user_group_ids)) + ) +>>>>>>> 43458cb ([17.0][FIX] base_user_role: Group synchronization fix for auditlog integration tests)