Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][FIX] auditlog: patch away all write overrides in res.groups for test (forward port) #3147

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions auditlog/tests/test_multi_company.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from unittest.mock import patch

from odoo.fields import Command
from odoo.models import BaseModel
from odoo.tests.common import TransactionCase

from odoo.addons.base.models.res_users import Groups


class TestMultiCompany(TransactionCase):
@classmethod
Expand Down Expand Up @@ -78,10 +77,12 @@ def write(self, vals):
present in the cache at this point, leading to the deletion of the
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.
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)]})
self.assertEqual(group_with_user.users, self.user2)
# Ensure that the users of the other companies are still there.
Expand Down
Loading