[FIX] portal: mail_message override: do not check access rules for SUPERUSER_ID

bzr revid: tde@openerp.com-20131114123346-dbnrkh6nadl774qe
This commit is contained in:
Thibault Delavallée 2013-11-14 13:33:46 +01:00
parent e5ca5a170c
commit ebe580f481
1 changed files with 6 additions and 0 deletions

View File

@ -19,6 +19,7 @@
#
##############################################################################
from openerp import SUPERUSER_ID
from openerp.osv import osv, orm
from openerp.tools.translate import _
@ -32,6 +33,9 @@ class mail_message(osv.Model):
""" Override that adds specific access rights of mail.message, to remove
all internal notes if uid is a non-employee
"""
if uid == SUPERUSER_ID:
return super(mail_message, self)._search(cr, uid, args, offset=offset, limit=limit, order=order,
context=context, count=False, access_rights_uid=access_rights_uid)
group_ids = self.pool.get('res.users').browse(cr, uid, uid, context=context).groups_id
group_user_id = self.pool.get("ir.model.data").get_object_reference(cr, uid, 'base', 'group_user')[1]
if group_user_id not in [group.id for group in group_ids]:
@ -45,6 +49,8 @@ class mail_message(osv.Model):
- read:
- raise if the type is comment and subtype NULL (internal note)
"""
if uid == SUPERUSER_ID:
return super(mail_message, self).check_access_rule(cr, uid, ids=ids, operation=operation, context=context)
group_ids = self.pool.get('res.users').browse(cr, uid, uid, context=context).groups_id
group_user_id = self.pool.get("ir.model.data").get_object_reference(cr, uid, 'base', 'group_user')[1]
if group_user_id not in [group.id for group in group_ids]: