[FIX] mail: avoid duplicate entries in model mail.channel.partner
in some cases, it is possible to call the method channel_join_and_getinfo when the user is already in the channel. This may (and did) cause issues in some unrelated code. This commit guarantees that this codepath will avoir creating another entry. Another way to achieve this result is by adding a constraint on the model mail.channel.partner, but this is in 9.0, so we must be careful.
This commit is contained in:
committed by
Aaron Bohy
parent
8ef69bd9fb
commit
62829ac364
@@ -142,7 +142,10 @@ class Channel(models.Model):
|
||||
|
||||
@api.multi
|
||||
def action_follow(self):
|
||||
return self.write({'channel_last_seen_partner_ids': [(0, 0, {'partner_id': self.env.user.partner_id.id})]})
|
||||
self.ensure_one()
|
||||
channel_partner = self.mapped('channel_last_seen_partner_ids').filtered(lambda cp: cp.partner_id == self.env.user.partner_id)
|
||||
if not channel_partner:
|
||||
return self.write({'channel_last_seen_partner_ids': [(0, 0, {'partner_id': self.env.user.partner_id.id})]})
|
||||
|
||||
@api.multi
|
||||
def action_unfollow(self):
|
||||
|
||||
Reference in New Issue
Block a user