summaryrefslogtreecommitdiff
path: root/addons/mail
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2021-01-18 17:58:06 +0000
committerSébastien Theys <seb@odoo.com>2021-01-18 17:58:06 +0000
commita27907e27fb99a523c7b2d58544c36073640511c (patch)
tree081852a72fc103e85212760afb75ace43d0461c9 /addons/mail
parent298f3900a8f4c80fe06585634ce97c7725cf7f7d (diff)
[FIX] mail: properly return last message id for channel in mobile
This mobile specific code does not work correctly because `if channel in channel_previews` always returns false due to the dict having channel ids as key and not channels. A fix could be to look for id instead of record in the dict, but at the same time this is dead code, there is no need for mobile specific channel info. task-2412157 closes odoo/odoo#64722 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/mail')
-rw-r--r--addons/mail/models/mail_channel.py17
1 files changed, 2 insertions, 15 deletions
diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py
index 84c3399fd69..a75a9204dd1 100644
--- a/addons/mail/models/mail_channel.py
+++ b/addons/mail/models/mail_channel.py
@@ -592,13 +592,7 @@ class Channel(models.Model):
direct_channel_partners = all_partner_channel.filtered(lambda pc: channel_dict[pc.channel_id.id].channel_type == 'chat')
direct_partners = direct_channel_partners.mapped('partner_id')
partner_infos = self.partner_info(all_partners, direct_partners)
-
- # add last message preview (only used in mobile)
- addPreview = self._context.get('isMobile', False)
- if addPreview:
- channel_previews = {channel_preview['id']: channel_preview for channel_preview in self.channel_fetch_preview()}
- else:
- channel_last_message_ids = dict((r['id'], r['message_id']) for r in self._channel_last_message_ids())
+ channel_last_message_ids = dict((r['id'], r['message_id']) for r in self._channel_last_message_ids())
for channel in self:
info = {
@@ -619,14 +613,7 @@ class Channel(models.Model):
info['info'] = extra_info
# add last message preview (only used in mobile)
- if addPreview:
- if channel in channel_previews:
- info['last_message'] = channel_previews[channel]
- info['last_message_id'] = channel_previews[channel]['last_message']['id']
- else:
- info['last_message_id'] = False
- else:
- info['last_message_id'] = channel_last_message_ids.get(channel.id, False)
+ info['last_message_id'] = channel_last_message_ids.get(channel.id, False)
# listeners of the channel
channel_partners = all_partner_channel.filtered(lambda pc: channel.id == pc.channel_id.id)