Skip to content
Permalink
Browse files

[FIX] mail: do not crash if a partner has more than one mail.channel.…

…partner

It is assumed that there is a unique mail.channel.partner per (channel, partner)
pair, yet there is nothing enforcing this restriction.
As a result field access on the channel partner crashes on field access.
  • Loading branch information...
len-odoo authored and KangOl committed Feb 19, 2019
1 parent 0f4abc5 commit 8f8b94596eea50a6e0507da49cad47b50c6e3878
Showing with 2 additions and 2 deletions.
  1. +2 −2 addons/mail/models/mail_channel.py
@@ -730,7 +730,7 @@ def channel_seen(self):
self.ensure_one()
if self.channel_message_ids.ids:
last_message_id = self.channel_message_ids.ids[0] # zero is the index of the last message
channel_partner = self.env['mail.channel.partner'].search([('channel_id', 'in', self.ids), ('partner_id', '=', self.env.user.partner_id.id)])
channel_partner = self.env['mail.channel.partner'].search([('channel_id', 'in', self.ids), ('partner_id', '=', self.env.user.partner_id.id)], limit=1)
if channel_partner.seen_message_id.id == last_message_id:
# last message seen by user is already up-to-date
return
@@ -761,7 +761,7 @@ def channel_fetched(self):
if channel.channel_type != 'chat':
return
last_message_id = channel.channel_message_ids.ids[0] # zero is the index of the last message
channel_partner = self.env['mail.channel.partner'].search([('channel_id', '=', channel.id), ('partner_id', '=', self.env.user.partner_id.id)])
channel_partner = self.env['mail.channel.partner'].search([('channel_id', '=', channel.id), ('partner_id', '=', self.env.user.partner_id.id)], limit=1)
if channel_partner.fetched_message_id.id == last_message_id:
# last message fetched by user is already up-to-date
return

0 comments on commit 8f8b945

Please sign in to comment.
You can’t perform that action at this time.