From 1dfd1bd7a337b790f48d00025335c4cecc0b2663 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Thu, 19 Nov 2015 15:46:39 +0100 Subject: [PATCH] [FIX] mail: correctly pin DM's on message post DM channels are supposed to be pinned on each partner's side when a message is post in the DM. This didn't work because we checked if the channel is a DM by comparing its type to 'direct_message', which is not a valid channel type. Also stop marking the DM as pinned in channel_join_and_get_info() as it is now useless. --- addons/mail/models/mail_channel.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py index 32ee04fe66c..ee4ed01b324 100644 --- a/addons/mail/models/mail_channel.py +++ b/addons/mail/models/mail_channel.py @@ -184,7 +184,7 @@ class Channel(models.Model): @api.returns('self', lambda value: value.id) def message_post(self, body='', subject=None, message_type='notification', subtype=None, parent_id=False, attachments=None, content_subtype='html', **kwargs): # auto pin 'direct_message' channel partner - self.filtered(lambda channel: channel.channel_type == 'direct_message').mapped('channel_last_seen_partner_ids').write({'is_pinned': True}) + self.filtered(lambda channel: channel.channel_type == 'chat').mapped('channel_last_seen_partner_ids').write({'is_pinned': True}) # apply shortcode (text only) subsitution body = self.env['mail.shortcode'].apply_shortcode(body, shortcode_type='text') message = super(Channel, self.with_context(mail_create_nosubscribe=True)).message_post(body=body, subject=subject, message_type=message_type, subtype=subtype, parent_id=parent_id, attachments=attachments, content_subtype=content_subtype, **kwargs) @@ -497,8 +497,6 @@ class Channel(models.Model): if self.channel_type == 'channel': notification = _('
joined #%s
') % (self.id, self.name,) self.message_post(body=notification, message_type="notification", subtype="mail.mt_comment") - else: - self.channel_last_seen_partner_ids.write({'is_pinned': True}) self.action_follow() channel_info = self.channel_info()[0]