[FIX] mail: receiving a notification without notifying the parent message.

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
This commit is contained in:
Goffin Simon 2016-05-18 14:07:54 +02:00
parent 0fc73a2067
commit fac04424ca
1 changed files with 11 additions and 8 deletions

View File

@ -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