[FIX] event: fixed the access rights in order to have that being in the manager group...
[odoo/odoo.git] / addons / event_share / wizard / wizard_share.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2011 OpenERP S.A (<http://www.openerp.com>).
6 #
7 #    This program is free software: you can redistribute it and/or modify
8 #    it under the terms of the GNU Affero General Public License as
9 #    published by the Free Software Foundation, either version 3 of the
10 #    License, or (at your option) any later version.
11 #
12 #    This program is distributed in the hope that it will be useful,
13 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 #    GNU Affero General Public License for more details.
16 #
17 #    You should have received a copy of the GNU Affero General Public License
18 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20 ##############################################################################
21
22 from osv import osv, fields
23 from tools.translate import _
24
25 UID_ROOT = 1
26 EVENT_ACCESS = ('perm_read', 'perm_write', 'perm_create')
27
28 class share_wizard_event(osv.osv_memory):
29     """Inherited share wizard to automatically create appropriate
30        menus in the selected portal upon sharing with a portal group."""
31     _inherit = "share.wizard"
32     
33     def _add_access_rights_for_share_group(self, cr, uid, group_id, mode, fields_relations, context=None):
34         """Adds access rights to group_id on object models referenced in ``fields_relations``,
35            intersecting with access rights of current user to avoid granting too much rights
36         """
37         res = super(share_wizard_event, self)._add_access_rights_for_share_group(cr, uid, group_id, mode, fields_relations, context=context)
38         access_model = self.pool.get('ir.model.access')
39         
40         access_ids =  access_model.search(cr,uid,[('group_id','=',group_id)],context = context)
41         for record in access_model.browse(cr,uid,access_ids,context = context):
42             if record.model_id.model == 'event.registration':
43                 access_model.write(cr, uid, record.id, {'perm_read': True, 'perm_write': True,'perm_create':True})
44
45 share_wizard_event()
46
47
48 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: