summaryrefslogtreecommitdiff
path: root/addons/mail/models/mail_thread.py
diff options
context:
space:
mode:
authorstd-odoo <std@odoo.com>2020-05-05 07:33:38 +0000
committerstd-odoo <std@odoo.com>2020-05-27 05:53:13 +0000
commit635519ae29202e11c93f973e78d922e983e9f5ee (patch)
treeb759cad8ff2863b4e924658174d99e576a23fed8 /addons/mail/models/mail_thread.py
parentc25f4359942a9ee0035cb08bc69a0c25c6f8258f (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/mail/models/mail_thread.py')
-rw-r--r--addons/mail/models/mail_thread.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py
index 5786a4ed357..5acd5604ad0 100644
--- a/addons/mail/models/mail_thread.py
+++ b/addons/mail/models/mail_thread.py
@@ -535,15 +535,17 @@ class MailThread(models.AbstractModel):
# Automatic log / Tracking
# ------------------------------------------------------
- @tools.ormcache()
+ @tools.ormcache('self.env.uid', 'self.env.su')
def _get_tracked_fields(self):
""" Return the set of tracked fields names for the current model. """
- return {
+ fields = {
name
for name, field in self._fields.items()
if getattr(field, 'tracking', None) or getattr(field, 'track_visibility', None)
}
+ return fields and set(self.fields_get(fields))
+
def _creation_subtype(self):
""" Give the subtypes triggered by the creation of a record