diff options
| author | std-odoo <std@odoo.com> | 2020-05-05 07:33:38 +0000 |
|---|---|---|
| committer | std-odoo <std@odoo.com> | 2020-05-27 05:53:13 +0000 |
| commit | 635519ae29202e11c93f973e78d922e983e9f5ee (patch) | |
| tree | b759cad8ff2863b4e924658174d99e576a23fed8 /addons/test_mail | |
| parent | c25f4359942a9ee0035cb08bc69a0c25c6f8258f (diff) | |
[FIX] mail: fix tracked field with groups
Bug
===
Since 0bd14547a7f6389192f522da08527a2c8a13f1a8,
When editing a record which has a tracked field with a group, and if
the current user is not in the group, an error is raised.
Technical
=========
When we get the tracked fields, we must care about the group of the
current user and keep only the tracked fields the user have access to.
To do that, we use `fields_get`, which will return only fields accessible
by the current user group.
The method `_get_tracked_fields` is cached, but it need to depend on
the current user (and also if we are in sudo mode or not), because the
function will return different results, depending on the group of the
user.
Task-2250070
closes odoo/odoo#51915
X-original-commit: c7010058a93ca2fd3b65ac978d8333b273f04fac
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Diffstat (limited to 'addons/test_mail')
| -rw-r--r-- | addons/test_mail/tests/test_message_track.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/addons/test_mail/tests/test_message_track.py b/addons/test_mail/tests/test_message_track.py index 3050951f45f..df024c1e094 100644 --- a/addons/test_mail/tests/test_message_track.py +++ b/addons/test_mail/tests/test_message_track.py @@ -5,6 +5,7 @@ from unittest.mock import patch from odoo.addons.test_mail.tests.common import TestMailCommon from odoo.tests.common import tagged +from odoo.tests import Form @tagged('mail_track') @@ -313,6 +314,17 @@ class TestTrackingInternals(TestMailCommon): self.assertFalse(msg_emp.get('tracking_values'), "should not have protected tracking values") self.assertTrue(msg_sudo.get('tracking_values'), "should have protected tracking values") + # test editing the record with user not in the group of the field + self.record.invalidate_cache() + self.record.clear_caches() + record_form = Form(self.record.with_user(self.user_employee)) + record_form.name = 'TestDoNoCrash' + # the employee user must be able to save the fields on which he can write + # if we fetch all the tracked fields, ignoring the group of the current user + # it will crash and it shouldn't + record = record_form.save() + self.assertEqual(record.name, 'TestDoNoCrash') + def test_track_sequence(self): """ Update some tracked fields and check that the mail.tracking.value are ordered according to their tracking_sequence""" self.record.write({ |
