[IMP] base: use helper methods for implied groups
In this PR, we add a helper method to add/remove implied groups - update the base to use these instead Task 2610735
This commit is contained in:
@@ -577,10 +577,9 @@ class ResConfigSettings(models.TransientModel, ResConfigModuleInstallationMixin)
|
|||||||
if self[name] == current_settings[name]:
|
if self[name] == current_settings[name]:
|
||||||
continue
|
continue
|
||||||
if int(self[name]):
|
if int(self[name]):
|
||||||
groups.write({'implied_ids': [Command.link(implied_group.id)]})
|
groups._apply_group(implied_group)
|
||||||
else:
|
else:
|
||||||
groups.write({'implied_ids': [Command.unlink(implied_group.id)]})
|
groups._remove_group(implied_group)
|
||||||
implied_group.write({'users': [Command.unlink(user.id) for user in groups.users]})
|
|
||||||
|
|
||||||
# config fields: store ir.config_parameters
|
# config fields: store ir.config_parameters
|
||||||
IrConfigParameter = self.env['ir.config_parameter'].sudo()
|
IrConfigParameter = self.env['ir.config_parameter'].sudo()
|
||||||
|
|||||||
@@ -1091,6 +1091,21 @@ class GroupsImplied(models.Model):
|
|||||||
self._check_one_user_type()
|
self._check_one_user_type()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def _apply_group(self, implied_group):
|
||||||
|
""" Add the given group to the groups implied by the current group
|
||||||
|
:param implied_group: the implied group to add
|
||||||
|
"""
|
||||||
|
if implied_group not in self.implied_ids:
|
||||||
|
self.write({'implied_ids': [Command.link(implied_group.id)]})
|
||||||
|
|
||||||
|
def _remove_group(self, implied_group):
|
||||||
|
""" Remove the given group from the implied groups of the current group
|
||||||
|
:param implied_group: the implied group to remove
|
||||||
|
"""
|
||||||
|
if implied_group in self.implied_ids:
|
||||||
|
self.write({'implied_ids': [Command.unlink(implied_group.id)]})
|
||||||
|
implied_group.write({'users': [Command.unlink(user.id) for user in self.users]})
|
||||||
|
|
||||||
class UsersImplied(models.Model):
|
class UsersImplied(models.Model):
|
||||||
_inherit = 'res.users'
|
_inherit = 'res.users'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user