summaryrefslogtreecommitdiff
path: root/addons/mail/models/mail_message.py
diff options
context:
space:
mode:
authorXavier Dollé <xdo@odoo.com>2018-05-16 12:53:32 +0200
committerThibault Delavallée <tde@odoo.com>2018-05-16 16:00:06 +0200
commit69714fbeee479cd3e0f89de39b3687c183791fc0 (patch)
tree5e8c00f007f8b2a22711181f9f90f6ebb6ee5629 /addons/mail/models/mail_message.py
parent0984b2aadb0156e1f742f0bf14f8d36b6d170f23 (diff)
[FIX] mail: correctly filter needaction on unread notifications in message_format
Previously to this commit needaction used by JS was not taking into account read notifications. It means notably Inbox counter could be higher than expected as taking into account read messages while Inbox displays only unread messages. This commit fixes that by checking notification state when giving needaction_partner_ids to message_format result. This fix has a small impact on performances as message_format is used in notification process for chat or push. A better implementation of message format and its postprocess could probably lessen this fix impact. As we target stable version we avoid rewriting other part of the code. Optimization will be done in development version. Related to task ID 1841243.
Diffstat (limited to 'addons/mail/models/mail_message.py')
-rw-r--r--addons/mail/models/mail_message.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/addons/mail/models/mail_message.py b/addons/mail/models/mail_message.py
index 89e4237c8e1..cee1c692632 100644
--- a/addons/mail/models/mail_message.py
+++ b/addons/mail/models/mail_message.py
@@ -401,7 +401,6 @@ class Message(models.Model):
'message_type', 'subtype_id', 'subject', # message specific
'model', 'res_id', 'record_name', # document related
'channel_ids', 'partner_ids', # recipients
- 'needaction_partner_ids', # list of partner ids for whom the message is a needaction
'starred_partner_ids', # list of partner ids for whom the message is starred
])
message_tree = dict((m.id, m) for m in self.sudo())
@@ -414,6 +413,7 @@ class Message(models.Model):
subtypes_dict = dict((subtype['id'], subtype) for subtype in subtypes)
xml_comment_id = self.env.ref('mail.mt_comment').id
for message in message_values:
+ message['needaction_partner_ids'] = self.env['mail.notification'].sudo().search([('mail_message_id', '=', message['id']), ('is_read', '=', False)]).mapped('res_partner_id').ids
message['is_note'] = message['subtype_id'] and subtypes_dict[message['subtype_id'][0]]['internal']
message['is_discussion'] = message['subtype_id'] and subtypes_dict[message['subtype_id'][0]]['id'] == xml_comment_id
message['subtype_description'] = message['subtype_id'] and subtypes_dict[message['subtype_id'][0]]['description']