summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToufik Ben Jaa <tbe@odoo.com>2019-05-09 11:10:12 +0000
committerToufik Ben Jaa <tbe@odoo.com>2019-05-09 11:10:12 +0000
commit9530f1071d816d76194ee57711192f709e4d4d19 (patch)
treea8a29feb9d133553b40ff4909ad6862409a55b66
parente244fa23ade0944d578e2b843eed856e1c327d57 (diff)
[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 <chs@odoo.com>
-rw-r--r--addons/mail/models/mail_channel.py3
1 files changed, 2 insertions, 1 deletions
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