summaryrefslogtreecommitdiff
path: root/addons/portal_rating
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2020-03-06 11:11:29 +0000
committerSébastien Theys <seb@odoo.com>2020-03-06 16:15:44 +0000
commite3afe4d067e9e4eec54e0f0eadfd7316ae57dc99 (patch)
tree3708b51994a37a48bd9df04ffbbf78a6ce7a78f1 /addons/portal_rating
parent2490676e16964eaaf5a7c5ecb2525883c15dc6ab (diff)
[IMP] models, (test_)mail, portal(_rating): remove `message_tree`
from `message_format` and from `_message_read_dict_postprocess`. The reading and initial formatting is done by `_message_read_dict_postprocess`, which has been renamed more simply to `_message_format` due to its new goal. This makes the methods easier to follow and does not increase the query count. It actually reduces it when the data were already in the cache, by not always reading them again. Part of task-2180311 PR: #43841
Diffstat (limited to 'addons/portal_rating')
-rw-r--r--addons/portal_rating/models/mail_message.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/addons/portal_rating/models/mail_message.py b/addons/portal_rating/models/mail_message.py
index 9f2be5d1a25..20716960503 100644
--- a/addons/portal_rating/models/mail_message.py
+++ b/addons/portal_rating/models/mail_message.py
@@ -13,16 +13,16 @@ class MailMessage(models.Model):
field_list += ['rating_value']
return super(MailMessage, self)._portal_message_format(field_list)
- def _message_read_dict_postprocess(self, message_values, message_tree):
+ def _message_format(self, fnames):
""" Override the method to add information about a publisher comment
on each rating messages if requested, and compute a plaintext value of it.
"""
- res = super(MailMessage, self)._message_read_dict_postprocess(message_values, message_tree)
+ vals_list = super(MailMessage, self)._message_format(fnames)
if self._context.get('rating_include'):
infos = ["id", "publisher_comment", "publisher_id", "publisher_datetime", "message_id"]
related_rating = self.env['rating.rating'].sudo().search([('message_id', 'in', self.ids)]).read(infos)
mid_rating_tree = dict((rating['message_id'][0], rating) for rating in related_rating)
- for values in message_values:
- values["rating"] = mid_rating_tree.get(values['id'], {})
- return res
+ for vals in vals_list:
+ vals["rating"] = mid_rating_tree.get(vals['id'], {})
+ return vals_list