diff --git a/addons/im_livechat/models/mail_channel.py b/addons/im_livechat/models/mail_channel.py index 4572ba64848..982c4751701 100644 --- a/addons/im_livechat/models/mail_channel.py +++ b/addons/im_livechat/models/mail_channel.py @@ -36,6 +36,13 @@ class MailChannel(models.Model): channel_type = fields.Selection(selection_add=[('livechat', 'Livechat Conversation')]) livechat_channel_id = fields.Many2one('im_livechat.channel', 'Channel') + @api.multi + def _compute_is_chat(self): + super(MailChannel, self)._compute_is_chat() + for record in self: + if record.channel_type == 'livechat': + record.is_chat = True + @api.multi def _channel_message_notifications(self, message): """ When a anonymous user create a mail.channel, the operator is not notify (to avoid massive polling when diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py index 13cbb4644a1..b1772eb047e 100644 --- a/addons/mail/models/mail_channel.py +++ b/addons/mail/models/mail_channel.py @@ -78,6 +78,7 @@ class Channel(models.Model): ('chat', 'Chat Discussion'), ('channel', 'Channel')], 'Channel Type', default='channel') + is_chat = fields.Boolean(string='Is a chat', compute='_compute_is_chat', default=False) description = fields.Text('Description') uuid = fields.Char('UUID', size=50, index=True, default=lambda self: str(uuid4()), copy=False) email_send = fields.Boolean('Send messages by email', default=False) @@ -178,6 +179,12 @@ class Channel(models.Model): for record in self: record.is_member = record in membership_ids + @api.multi + def _compute_is_chat(self): + for record in self: + if record.channel_type == 'chat': + record.is_chat = True + @api.onchange('public') def _onchange_public(self): if self.public == 'public': @@ -384,7 +391,7 @@ class Channel(models.Model): if moderation_status == 'rejected': return self.env['mail.message'] - self.filtered(lambda channel: channel.channel_type == 'chat').mapped('channel_last_seen_partner_ids').write({'is_pinned': True}) + self.filtered(lambda channel: channel.is_chat).mapped('channel_last_seen_partner_ids').write({'is_pinned': True}) message = super(Channel, self.with_context(mail_create_nosubscribe=True)).message_post(message_type=message_type, moderation_status=moderation_status, **kwargs)