[FIX] auditlog: patch away all write overrides in res.groups for test

pull/3147/head
Holger Brunn 2024-12-12 14:08:53 +01:00 committed by Miquel Raïch
parent bde93913a5
commit 932a623c30
1 changed files with 5 additions and 4 deletions

View File

@ -1,10 +1,9 @@
from unittest.mock import patch from unittest.mock import patch
from odoo.fields import Command from odoo.fields import Command
from odoo.models import BaseModel
from odoo.tests.common import TransactionCase from odoo.tests.common import TransactionCase
from odoo.addons.base.models.res_users import Groups
class TestMultiCompany(TransactionCase): class TestMultiCompany(TransactionCase):
@classmethod @classmethod
@ -78,10 +77,12 @@ class TestMultiCompany(TransactionCase):
present in the cache at this point, leading to the deletion of the present in the cache at this point, leading to the deletion of the
value from the company that is inaccessible to the current user. value from the company that is inaccessible to the current user.
""" """
return super(Groups, self).write(vals) return BaseModel.write(self, vals)
# Do the write. # Do the write.
with patch.object(Groups, "write", side_effect=write, autospec=True): with patch.object(
self.env["res.groups"].__class__, "write", side_effect=write, autospec=True
):
group_with_user.write({"users": [Command.set(self.user2.ids)]}) group_with_user.write({"users": [Command.set(self.user2.ids)]})
self.assertEqual(group_with_user.users, self.user2) self.assertEqual(group_with_user.users, self.user2)
# Ensure that the users of the other companies are still there. # Ensure that the users of the other companies are still there.