[CLEAN] mail_followers: cleaned set_message_read code.
authorThibault Delavallée <tde@openerp.com>
Tue, 16 Oct 2012 07:57:19 +0000 (09:57 +0200)
committerThibault Delavallée <tde@openerp.com>
Tue, 16 Oct 2012 07:57:19 +0000 (09:57 +0200)
bzr revid: tde@openerp.com-20121016075719-qba8zt9gp6lvwmpn

addons/mail/mail_followers.py

index 6f122a8..eba8adf 100644 (file)
@@ -84,14 +84,8 @@ class mail_notification(osv.Model):
         return False
 
     def set_message_read(self, cr, uid, msg_ids, read=None, context=None):
-        if msg_ids == None:
-            return False
-        if type(msg_ids) is not list:
-            msg_ids=[msg_ids]
-
-        partner_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).partner_id.id
-        notif_ids = self.search(cr, uid, [('partner_id', '=', partner_id), ('message_id', 'in', msg_ids)], context=context)
-
+        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), ('message_id', 'in', msg_ids)], context=context)
         return self.write(cr, uid, notif_ids, {'read': read}, context=context)
 
     def get_partners_to_notify(self, cr, uid, message, context=None):