mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[IMP] Fix edition of role
This commit is contained in:
@@ -47,6 +47,14 @@ class ResUsersRole(models.Model):
|
|||||||
return new_record
|
return new_record
|
||||||
|
|
||||||
def write(self, vals):
|
def write(self, vals):
|
||||||
|
# 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 = {}
|
||||||
|
for field in self.group_id._fields:
|
||||||
|
if field in vals:
|
||||||
|
groups_vals[field] = vals.pop(field)
|
||||||
|
if groups_vals:
|
||||||
|
self.group_id.write(groups_vals)
|
||||||
res = super(ResUsersRole, self).write(vals)
|
res = super(ResUsersRole, self).write(vals)
|
||||||
self.update_users()
|
self.update_users()
|
||||||
return res
|
return res
|
||||||
|
|||||||
@@ -224,3 +224,8 @@ class TestUserRole(TransactionCase):
|
|||||||
role_group_ids = sorted(set(role_group_ids))
|
role_group_ids = sorted(set(role_group_ids))
|
||||||
# Check that user have groups implied by role 2
|
# Check that user have groups implied by role 2
|
||||||
self.assertEqual(user_group_ids, role_group_ids)
|
self.assertEqual(user_group_ids, role_group_ids)
|
||||||
|
|
||||||
|
def test_update_role(self):
|
||||||
|
self.role1_id.write({"name": "foo", "comment": "FOO"})
|
||||||
|
self.assertEqual(self.role1_id.group_id.name, "foo")
|
||||||
|
self.assertEqual(self.role1_id.group_id.comment, "FOO")
|
||||||
|
|||||||
Reference in New Issue
Block a user