diff options
| author | Xavier Dollé <xdo@odoo.com> | 2018-05-16 12:53:32 +0200 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2018-05-16 16:00:43 +0200 |
| commit | 19fb650863f11172c8a6839fcc10919e9ca9977b (patch) | |
| tree | ef7d60e97b8e80b1ddd9b98194c472c9c5e1471a /addons/mail/models/mail_message.py | |
| parent | 491243d1caa46b75a08a656a0049e79fd7597258 (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. This is a manual backport of commit 69714fbeee479cd3e0f89de39b3687c183791fc0
done in saas-11.2.
Diffstat (limited to 'addons/mail/models/mail_message.py')
| -rw-r--r-- | addons/mail/models/mail_message.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/addons/mail/models/mail_message.py b/addons/mail/models/mail_message.py index 62f0f524ebf..01bc5e71a5a 100644 --- a/addons/mail/models/mail_message.py +++ b/addons/mail/models/mail_message.py @@ -411,7 +411,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()) @@ -423,6 +422,7 @@ class Message(models.Model): subtypes = self.env['mail.message.subtype'].sudo().browse(subtype_ids).read(['internal', 'description']) subtypes_dict = dict((subtype['id'], subtype) for subtype in subtypes) 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['subtype_description'] = message['subtype_id'] and subtypes_dict[message['subtype_id'][0]]['description'] if message['model'] and self.env[message['model']]._original_module: |
