From fac04424caa095511b0f809b351fc2af0a5942cc Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Wed, 18 May 2016 14:07:54 +0200 Subject: [PATCH] =?UTF-8?q?[FIX]=C2=A0mail:=20receiving=20a=20notification?= =?UTF-8?q?=20without=20notifying=20the=20parent=20message.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Used case: If you add a user which has no acces on a model(ex:purchase.order) as follower on a record of this model. When someone responded by email on this record, and when a message is sent on this record, an exception is raised at the connection of the user added as a follower. Fix: To have the rights to read the message, a read notification for this follower must be added to all parents of this message. Closes #11902 opw:676699 --- addons/mail/mail_message.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 5bf5c7f18c4..b66f41454cd 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -883,11 +883,14 @@ class mail_message(osv.Model): # An error appear when a user receive a notification without notifying # the parent message -> add a read notification for the parent if message.parent_id: - # all notified_partner_ids of the mail.message have to be notified for the parented messages - partners_to_parent_notify = set(message.notified_partner_ids).difference(message.parent_id.notified_partner_ids) - for partner in partners_to_parent_notify: - notification_obj.create(cr, uid, { - 'message_id': message.parent_id.id, - 'partner_id': partner.id, - 'is_read': True, - }, context=context) + parent_id = message.parent_id + while parent_id: + # all notified_partner_ids of the mail.message have to be notified for the parented messages + partners_to_parent_notify = set(message.notified_partner_ids).difference(parent_id.notified_partner_ids) + for partner in partners_to_parent_notify: + notification_obj.create(cr, uid, { + 'message_id': parent_id.id, + 'partner_id': partner.id, + 'is_read': True, + }, context=context) + parent_id = parent_id.parent_id