[FIX] base: fix users' groups assignation
Avoid sharing of users'groups when writing on multiple users. When changing groups of multiple users, all implied groups were shared between written users. Oversight of new-api rewrite. Fixes #26036
This commit is contained in:
committed by
Christophe Simonis
parent
e11908d429
commit
65ad60665e
@@ -679,7 +679,7 @@ class UsersImplied(models.Model):
|
||||
for user in self.with_context({}):
|
||||
gs = set(concat(g.trans_implied_ids for g in user.groups_id))
|
||||
vals = {'groups_id': [(4, g.id) for g in gs]}
|
||||
super(UsersImplied, self).write(vals)
|
||||
super(UsersImplied, user).write(vals)
|
||||
return res
|
||||
|
||||
#
|
||||
|
||||
@@ -31,3 +31,4 @@ import test_view_validation
|
||||
import test_views
|
||||
import test_xmlrpc
|
||||
import test_res_partner_bank
|
||||
import test_non_regression
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Non-Regression Tests
|
||||
"""
|
||||
|
||||
from openerp.tests.common import TransactionCase
|
||||
|
||||
|
||||
class TestNR(TransactionCase):
|
||||
def test_issue26036(self):
|
||||
U = self.env["res.users"]
|
||||
G = self.env["res.groups"]
|
||||
|
||||
group_A = G.create({"name": "A"})
|
||||
group_AA = G.create({"name": "AA", "implied_ids": [(6, 0, [group_A.id])]})
|
||||
group_B = G.create({"name": "B"})
|
||||
group_BB = G.create({"name": "BB", "implied_ids": [(6, 0, [group_B.id])]})
|
||||
group_C = G.create({"name": "C"})
|
||||
|
||||
user_a = U.create({"name": "a", "login": "a", "groups_id": [(6, 0, [group_AA.id])]})
|
||||
user_b = U.create({"name": "b", "login": "b", "groups_id": [(6, 0, [group_BB.id])]})
|
||||
|
||||
(user_a + user_b).write({"groups_id": [(4, group_C.id)]})
|
||||
|
||||
self.assertEqual(user_a.groups_id, (group_AA + group_A + group_C))
|
||||
self.assertEqual(user_b.groups_id, (group_BB + group_B + group_C))
|
||||
Reference in New Issue
Block a user