diff --git a/addons/portal/mail_message.py b/addons/portal/mail_message.py index d5acfdf74c1..d6a38f27378 100644 --- a/addons/portal/mail_message.py +++ b/addons/portal/mail_message.py @@ -48,7 +48,7 @@ class mail_message(osv.Model): 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]: - cr.execute('SELECT DISTINCT id FROM "%s" WHERE type = %%s AND subtype_id != NULL AND id = ANY (%%s)' % (self._table), ('comment', ids,)) + cr.execute('SELECT DISTINCT id FROM "%s" WHERE type = %%s AND subtype_id IS NULL AND id = ANY (%%s)' % (self._table), ('comment', ids,)) if cr.fetchall(): raise orm.except_orm(_('Access Denied'), _('The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: %s, Operation: %s)') % \ diff --git a/addons/portal/tests/test_portal.py b/addons/portal/tests/test_portal.py index 1cfb2aef269..c0b5709ac4f 100644 --- a/addons/portal/tests/test_portal.py +++ b/addons/portal/tests/test_portal.py @@ -150,3 +150,10 @@ class test_portal(TestMailBase): msg_ids = self.mail_message.search(cr, self.user_chell_id, [('model', '=', 'mail.group'), ('res_id', '=', group_port_id)]) self.assertEqual(set(msg_ids), set([msg1_id, msg2_id, msg3_id, msg5_id]), 'mail_message: portal user has access to messages he should not read') + + # Do: Chell read messages she can read + self.mail_message.read(cr, self.user_chell_id, msg_ids, ['body', 'type', 'subtype_id']) + + # Do: Chell read a message she should not be able to read + with self.assertRaises(except_orm): + self.mail_message.read(cr, self.user_chell_id, [msg4_id], ['body', 'type', 'subtype_id'])