[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>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user