From e46ddc2c21ecb067f9f5bcc06469ce08a73edac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 19 Oct 2012 14:06:16 +0200 Subject: [PATCH] [REV] mail_message: vote_toggle and favorite_toggle back as SUPERUSER_ID, because of access rights issues for people not being able to write on the mail.message. bzr revid: tde@openerp.com-20121019120616-pw8yop07fo1i2vu2 --- addons/mail/mail_message.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 0218f9a645c..8719d59bf04 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -163,13 +163,14 @@ class mail_message(osv.Model): #------------------------------------------------------ def vote_toggle(self, cr, uid, ids, context=None): - ''' Toggles vote. Performed using read to avoid access rights issues. ''' + ''' Toggles vote. Performed using read to avoid access rights issues. + Done as SUPERUSER_ID because uid may vote for a message he cannot modify. ''' for message in self.read(cr, uid, ids, ['vote_user_ids'], context=context): new_has_voted = not (uid in message.get('vote_user_ids')) if new_has_voted: - self.write(cr, uid, message.get('id'), {'vote_user_ids': [(4, uid)]}, context=context) + self.write(cr, SUPERUSER_ID, message.get('id'), {'vote_user_ids': [(4, uid)]}, context=context) else: - self.write(cr, uid, message.get('id'), {'vote_user_ids': [(3, uid)]}, context=context) + self.write(cr, SUPERUSER_ID, message.get('id'), {'vote_user_ids': [(3, uid)]}, context=context) return new_has_voted or False #------------------------------------------------------ @@ -177,13 +178,14 @@ class mail_message(osv.Model): #------------------------------------------------------ def favorite_toggle(self, cr, uid, ids, context=None): - ''' Toggles favorite. Performed using read to avoid access rights issues. ''' + ''' Toggles favorite. Performed using read to avoid access rights issues. + Done as SUPERUSER_ID because uid may star a message he cannot modify. ''' for message in self.read(cr, uid, ids, ['favorite_user_ids'], context=context): new_is_favorite = not (uid in message.get('favorite_user_ids')) if new_is_favorite: - self.write(cr, uid, message.get('id'), {'favorite_user_ids': [(4, uid)]}, context=context) + self.write(cr, SUPERUSER_ID, message.get('id'), {'favorite_user_ids': [(4, uid)]}, context=context) else: - self.write(cr, uid, message.get('id'), {'favorite_user_ids': [(3, uid)]}, context=context) + self.write(cr, SUPERUSER_ID, message.get('id'), {'favorite_user_ids': [(3, uid)]}, context=context) return new_is_favorite or False #------------------------------------------------------