[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:
sebalix
2017-09-21 11:21:34 +02:00
committed by Pedro M. Baeza
parent e63b03047b
commit 48703df707
3 changed files with 62 additions and 4 deletions

View File

@@ -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(