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 28, 2025
1 parent 1b94613 commit 908beda
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions 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 @@ -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)

0 comments on commit 908beda

Please sign in to comment.