[IMP] mail: create test for access rules. fix the create group: add user in follower and remove admin
bzr revid: chm@openerp.com-20121206102714-tm0w6bn234a2j4fn
This commit is contained in:
@@ -122,6 +122,10 @@ class mail_group(osv.Model):
|
||||
#ir.ui.menu (for which normal users do not have creation rights)
|
||||
self.check_access_rights(cr, uid, 'create')
|
||||
mail_group_id = super(mail_group, self).create(cr, SUPERUSER_ID, vals, context=context)
|
||||
if uid != SUPERUSER_ID:
|
||||
# creator is the first follower
|
||||
user_pid = self.pool.get('res.users').read(cr, uid, uid, ['partner_id'], context=context)['partner_id'][0]
|
||||
self.write(cr, SUPERUSER_ID, [mail_group_id], {'message_follower_ids': [(6, 0, [user_pid])]}, context=context)
|
||||
|
||||
# Create client action for this group and link the menu to it
|
||||
ref = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'mail', 'action_mail_group_feeds')
|
||||
|
||||
@@ -51,6 +51,8 @@ class test_mail_access_rights(test_mail_mockup.TestMailMockups):
|
||||
self.partner_bert_id = self.user_bert.partner_id.id
|
||||
self.user_raoul = self.res_users.browse(cr, uid, self.user_raoul_id)
|
||||
self.partner_raoul_id = self.user_raoul.partner_id.id
|
||||
self.user_admin = self.res_users.browse(cr, uid, uid)
|
||||
self.partner_admin_id = self.user_admin.partner_id.id
|
||||
|
||||
@mute_logger('openerp.addons.base.ir.ir_model','openerp.osv.orm')
|
||||
def test_00_mail_message_search_access_rights(self):
|
||||
@@ -201,3 +203,35 @@ class test_mail_access_rights(test_mail_mockup.TestMailMockups):
|
||||
self.mail_group.read(cr, user_raoul_id, self.group_pigs_id)
|
||||
# Do: Bert read Jobs, ok because group_public_id = employee
|
||||
self.mail_group.read(cr, user_raoul_id, self.group_jobs_id)
|
||||
|
||||
|
||||
def test_80_linked_document(self):
|
||||
""" Testing follower, mail and document relation. """
|
||||
cr, uid, user_admin = self.cr, self.uid, self.user_admin
|
||||
user_raoul_id, user_raoul = self.user_raoul_id, self.user_raoul
|
||||
|
||||
print ""
|
||||
print ""
|
||||
print ""
|
||||
print ""
|
||||
|
||||
|
||||
# Raoul create a document mail_group
|
||||
group_doc_id = self.mail_group.create(cr, user_raoul_id, {'name': 'Doc group'})
|
||||
group_doc = self.mail_group.browse(cr, user_raoul_id, group_doc_id)
|
||||
|
||||
print set([user_raoul.partner_id])
|
||||
print set(group_doc.message_follower_ids)
|
||||
|
||||
# Test: raoul is follower of the group he created
|
||||
self.assertEqual(set(group_doc.message_follower_ids), set([user_raoul.partner_id]), 'Group create failed, the creator must follow the document he created.')
|
||||
|
||||
|
||||
print user_raoul.partner_id
|
||||
print group_doc.message_follower_ids
|
||||
|
||||
print ""
|
||||
print ""
|
||||
print ""
|
||||
print ""
|
||||
raise
|
||||
Reference in New Issue
Block a user