mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[FIX+IMP] base_user_role: Several things:
* FIX: Update users' groups when a role is deleted * IMP: add some test cases to check user's groups when its last role line is removed * FIX: ensure that the user's groups are updated when its last role line is removed
This commit is contained in:
committed by
Bert Van Groenendael
parent
185d344943
commit
1c2d2c69d3
@@ -32,12 +32,13 @@ class ResUsers(models.Model):
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def set_groups_from_roles(self):
|
||||
def set_groups_from_roles(self, force=False):
|
||||
"""Set (replace) the groups following the roles defined on users.
|
||||
If no role is defined on the user, its groups are let untouched.
|
||||
If no role is defined on the user, its groups are let untouched unless
|
||||
the `force` parameter is `True`.
|
||||
"""
|
||||
for user in self:
|
||||
if not user.role_line_ids:
|
||||
if not user.role_line_ids and not force:
|
||||
continue
|
||||
group_ids = []
|
||||
role_lines = user.role_line_ids.filtered(
|
||||
|
||||
Reference in New Issue
Block a user