From eae08d39d630f21f7221ead529e9331c4e4775d4 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Tue, 17 Nov 2015 09:49:30 +0100 Subject: [PATCH] [FIX] mail: mark as read: notify correct partner When calling 'set_message_done' on a message which is a needaction for several partners, the method was executed as root. This was an issue for the triggered notification, as it was thus always sent to the admin. For example, when Demo user marked such a message as read, he never received the notification, but the Admin did, and its notification counter weirdly decreased, while the one of Demo user remained the same. --- addons/mail/models/mail_message.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/mail/models/mail_message.py b/addons/mail/models/mail_message.py index 3e93973dd82..e57409ebe3e 100644 --- a/addons/mail/models/mail_message.py +++ b/addons/mail/models/mail_message.py @@ -197,10 +197,12 @@ class Message(models.Model): partners in partner_ids if partner_ids is given. """ if not partner_ids: partner_ids = [self.env.user.partner_id.id] + new_value = {'needaction_partner_ids': [(3, pid) for pid in partner_ids]} if set(partner_ids) == set([self.env.user.partner_id.id]): # a user should be able to mark a message as done for him - self = self.sudo() - self.write({'needaction_partner_ids': [(3, pid) for pid in partner_ids]}) + self.sudo().write(new_value) + else: + self.write(new_value) channel_ids = [c.id for c in self.channel_ids] notification = {'type': 'mark_as_read', 'message_ids': [self.id], 'channel_ids': channel_ids}