Skip to content

Commit

Permalink
Fix customer admin cannot edit its own roles
Browse files Browse the repository at this point in the history
  • Loading branch information
fcayre committed Oct 14, 2024
1 parent 74fc916 commit a695b2d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion customer_team_manager/models/employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def _reset_roles(self):
user = users[0]
user.groups_id -= all_role_groups
if user.has_group("base.group_portal"):
user.groups_id |= self.roles.mapped("groups")
user.groups_id |= self.sudo().roles.mapped("groups")

@api.model
@api.returns("self", lambda value: value.id)
Expand Down
7 changes: 7 additions & 0 deletions customer_team_manager/tests/test_employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,10 @@ def test_sync_partner_to_employee(self):

for name, value in new_attrs.items():
self.assertEqual(getattr(empl, name), value, name)

def test_admin_can_change_its_own_roles(self):
it_role = self.env.ref("customer_team_manager.customer_role_it")
self.assertNotIn(it_role, self.admin.roles)

self.admin.sudo(self.user.id).roles |= it_role
self.assertIn(it_role, self.admin.roles)

0 comments on commit a695b2d

Please sign in to comment.