[MIG] base_user_role: Migration to 15.0

This commit is contained in:
Tatiana Deribina
2021-11-11 18:10:44 +02:00
committed by Arnaud Pineux
parent 85207789fd
commit f1f2d67a2f
7 changed files with 36 additions and 11 deletions

View File

@@ -44,11 +44,25 @@ class ResUsersRole(models.Model):
@api.model
def create(self, vals):
# Run method as super user to avoid problems with new groups creations
# by "Administrator/Access Right"
is_access_rights = self.env.user.has_group(
"base.group_erp_manager",
)
if self._name == "res.users.role" and is_access_rights:
self = self.sudo()
new_record = super(ResUsersRole, self).create(vals)
new_record.update_users()
return new_record
def write(self, vals):
# Run method as super user to avoid problems with new groups creations
# by "Administrator/Access Right"
is_access_rights = self.env.user.has_group(
"base.group_erp_manager",
)
if self._name == "res.users.role" and is_access_rights:
self = self.sudo()
# Workaround to solve issue with broken code in odoo that clear the cache
# during the write: see odoo/addons/base/models/res_users.py#L226
groups_vals = {}