1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2010-2012 OpenERP S.A. (<http://www.openerp.com>).
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.
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.
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/>.
20 ##############################################################################
21 from openerp.osv import osv
23 class ir_model_access(osv.Model):
24 _inherit = 'ir.model.access'
26 # overload group_names_with_access() to avoid returning sharing groups
27 # by filtering out groups with share=true.
28 def group_names_with_access(self, cr, model_name, access_mode):
29 """Returns the names of visible groups which have been granted ``access_mode`` on
30 the model ``model_name``.
33 assert access_mode in ['read','write','create','unlink'], 'Invalid access mode: %s' % access_mode
38 JOIN ir_model m ON (a.model_id=m.id)
39 JOIN res_groups g ON (a.group_id=g.id)
40 LEFT JOIN ir_module_category c ON (c.id=g.category_id)
43 (g.share IS NULL or g.share IS false) AND
44 a.perm_''' + access_mode, (model_name,))
45 return [('%s/%s' % x) if x[0] else x[1] for x in cr.fetchall()]
48 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: