From 9530f1071d816d76194ee57711192f709e4d4d19 Mon Sep 17 00:00:00 2001 From: Toufik Ben Jaa Date: Thu, 9 May 2019 11:10:12 +0000 Subject: [PATCH] [FIX] mail: avoid crash when calling `channel_info` in `mail.channel` - If a channel has only the current user as the partner the method `channel_info` crashes. This can happen in the case of a partner talks to an other partner in discuss. Then these two partners are merged using the CRM partner merge feature. The channel has now the same partner in the channel twice. The current code doesn't handle this case and crashes. closes odoo/odoo#33274 Signed-off-by: Christophe Simonis --- addons/mail/models/mail_channel.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py index b6bbe82407e..4b860440f6b 100644 --- a/addons/mail/models/mail_channel.py +++ b/addons/mail/models/mail_channel.py @@ -617,7 +617,8 @@ class Channel(models.Model): # direct_partner should be removed from channel info since we can find it from members and channel_type # we keep it know to avoid change tests and javascript direct_partner = channel_partners.filtered(lambda pc: pc.partner_id.id != self.env.user.partner_id.id) - info['direct_partner'] = [partner_infos[direct_partner[0].partner_id.id]] + if direct_partner: + info['direct_partner'] = [partner_infos[direct_partner[0].partner_id.id]] # add needaction and unread counter, since the user is logged info['message_needaction_counter'] = channel.message_needaction_counter info['message_unread_counter'] = channel.message_unread_counter