summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2019-06-25 08:47:31 +0000
committerSébastien Theys <seb@odoo.com>2019-06-25 08:47:31 +0000
commit3e6bbe93af76120dd13aa162b1ae2d0c665eea06 (patch)
treeeb1564d5f835b4e6c46bb7ea8abeb4040c0acfa8 /addons
parent37a82e62a249315841408ad1cc9032c2c6ad20fa (diff)
[IMP] mail: call _get_tracked_fields in batch
Before this commit `_get_tracked_fields` was not called in batch because it took the `updated_fields` parameter, but this parameter is not used. By removing the parameter and calling the method in batch, creating 1000 products takes 20% less time. Part of task-1918881 closes odoo/odoo#34347 Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/mail/models/mail_thread.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py
index e419c5430b8..720cf02c112 100644
--- a/addons/mail/models/mail_thread.py
+++ b/addons/mail/models/mail_thread.py
@@ -297,9 +297,9 @@ class MailThread(models.AbstractModel):
# post track template if a tracked field changed
if not self._context.get('mail_notrack'):
track_threads = threads.with_lang()
+ tracked_fields = self._get_tracked_fields()
for thread in track_threads:
create_values = create_values_list[thread.id]
- tracked_fields = self._get_tracked_fields(list(create_values))
changes = [field for field in tracked_fields if create_values.get(field)]
# based on tracked field to stay consistent with write
# we don't consider that a falsy field is a change, to stay consistent with previous implementation,
@@ -318,7 +318,7 @@ class MailThread(models.AbstractModel):
tracked_fields = None
if not self._context.get('mail_notrack'):
- tracked_fields = track_self._get_tracked_fields(list(values))
+ tracked_fields = track_self._get_tracked_fields()
if tracked_fields:
initial_values = dict((record.id, dict((key, getattr(record, key)) for key in tracked_fields))
for record in track_self)
@@ -547,9 +547,8 @@ class MailThread(models.AbstractModel):
# ------------------------------------------------------
@api.model
- def _get_tracked_fields(self, updated_fields):
+ def _get_tracked_fields(self):
""" Return a structure of tracked fields for the current model.
- :param list updated_fields: modified field names
:return dict: a dict mapping field name to description, containing on_change fields
"""
tracked_fields = []