[FIX] mail: notifications: fixed access rights issues when setting as read/unread for lambda users.
bzr revid: tde@openerp.com-20121107153822-j7f1a63a2ix66e5n
This commit is contained in:
parent
2799ba172c
commit
281a4d0801
|
@ -84,11 +84,13 @@ class mail_notification(osv.Model):
|
|||
return False
|
||||
|
||||
def set_message_read(self, cr, uid, msg_ids, read=None, context=None):
|
||||
""" Set a message and its child messages as (un)read for uid.
|
||||
""" Set messages as (un)read. Technically, the notifications related
|
||||
to uid are set to (un)read. If for some msg_ids there are missing
|
||||
notifications (i.e. due to load more or thread parent fetching),
|
||||
they are created.
|
||||
|
||||
:param bool read: read / unread
|
||||
:param bool read: (un)read notification
|
||||
"""
|
||||
# TDE note: use child_of or front-end send correct values ?
|
||||
user_pid = self.pool.get('res.users').read(cr, uid, uid, ['partner_id'], context=context)['partner_id'][0]
|
||||
notif_ids = self.search(cr, uid, [
|
||||
('partner_id', '=', user_pid),
|
||||
|
@ -100,10 +102,9 @@ class mail_notification(osv.Model):
|
|||
return self.write(cr, uid, notif_ids, {'read': read}, context=context)
|
||||
|
||||
# some messages do not have notifications: find which one, create notification, update read status
|
||||
exist_notification = dict.fromkeys(msg_ids, False)
|
||||
for notification in self.browse(cr, uid, notif_ids, context=context):
|
||||
exist_notification[notification.message_id] = True
|
||||
for msg_id in exist_notification.keys():
|
||||
notified_msg_ids = [notification.message_id.id for notification in self.browse(cr, uid, notif_ids, context=context)]
|
||||
to_create_msg_ids = list(set(msg_ids) - set(notified_msg_ids))
|
||||
for msg_id in to_create_msg_ids:
|
||||
self.create(cr, uid, {'partner_id': user_pid, 'read': read, 'message_id': msg_id}, context=context)
|
||||
return self.write(cr, uid, notif_ids, {'read': read}, context=context)
|
||||
|
||||
|
|
|
@ -7,12 +7,13 @@ access_mail_mail_system,mail.mail.system,model_mail_mail,base.group_system,1,1,1
|
|||
access_mail_followers_all,mail.followers.all,model_mail_followers,,1,0,0,0
|
||||
access_mail_followers_system,mail.followers.system,model_mail_followers,base.group_system,1,1,1,1
|
||||
access_mail_notification_all,mail.notification.all,model_mail_notification,,1,0,0,0
|
||||
access_mail_notification_aystem,mail.notification.system,model_mail_notification,base.group_system,1,1,1,1
|
||||
access_mail_notification_group_user,mail.notification.user,model_mail_notification,base.group_user,1,1,1,0
|
||||
access_mail_notification_system,mail.notification.system,model_mail_notification,base.group_system,1,1,1,1
|
||||
access_mail_group_all,mail.group.all,model_mail_group,,1,0,0,0
|
||||
access_mail_group_user,mail.group.user,model_mail_group,base.group_user,1,1,1,1
|
||||
access_mail_alias_all,mail.alias.all,model_mail_alias,,1,0,0,0
|
||||
access_mail_alias_user,mail.alias,model_mail_alias,base.group_user,1,1,1,0
|
||||
access_mail_alias_system,mail.alias,model_mail_alias,base.group_system,1,1,1,1
|
||||
access_mail_alias_user,mail.alias.user,model_mail_alias,base.group_user,1,1,1,0
|
||||
access_mail_alias_system,mail.alias.system,model_mail_alias,base.group_system,1,1,1,1
|
||||
access_mail_message_subtype_all,mail.message.subtype.all,model_mail_message_subtype,,1,0,0,0
|
||||
access_mail_vote_all,mail.vote.all,model_mail_vote,,1,1,1,1
|
||||
access_mail_favorite_all,mail.favorite.all,model_mail_favorite,,1,1,1,1
|
||||
|
|
|
|
@ -10,7 +10,7 @@
|
|||
<field name="domain_force">['|', '|', ('public', '=', 'public'), ('message_follower_ids', 'in', [user.partner_id.id]), '&', ('public','=','groups'), ('group_public_id','in', [g.id for g in user.groups_id])]</field>
|
||||
</record>
|
||||
|
||||
<record id="mail_followers_read_own" model="ir.rule">
|
||||
<record id="mail_followers_read_write_own" model="ir.rule">
|
||||
<field name="name">mail.followers: read and write its own entries</field>
|
||||
<field name="model_id" ref="model_mail_followers"/>
|
||||
<field name="domain_force">[('partner_id', '=', user.partner_id.id)]</field>
|
||||
|
@ -18,6 +18,14 @@
|
|||
<field name="perm_unlink" eval="False"/>
|
||||
</record>
|
||||
|
||||
<record id="mail_notification_read_write_own" model="ir.rule">
|
||||
<field name="name">mail.notification: read and write its own entries</field>
|
||||
<field name="model_id" ref="model_mail_notification"/>
|
||||
<field name="domain_force">[('partner_id', '=', user.partner_id.id)]</field>
|
||||
<field name="perm_create" eval="False"/>
|
||||
<field name="perm_unlink" eval="False"/>
|
||||
</record>
|
||||
|
||||
<!--
|
||||
This rule can not be uncommented, because we have a more wide method in mail.message. When we implement a many2one_variable field, we will be able to uncomment this.
|
||||
<record id="mail_message_read_partner_or_author" model="ir.rule">
|
||||
|
|
Loading…
Reference in New Issue