diff --git a/addons/share/res_users.py b/addons/share/res_users.py index 56a3887b52a..662150bc406 100644 --- a/addons/share/res_users.py +++ b/addons/share/res_users.py @@ -64,12 +64,3 @@ class res_groups(osv.osv): if hasattr(parent_class, 'init'): parent_class.init(cr) - def get_application_groups(self, cr, uid, domain=None, context=None): - if domain is None: - domain = [] - domain.append(('share', '=', False)) - return super(res_groups, self).get_application_groups(cr, uid, domain=domain, context=context) - - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/openerp/addons/base/res/res_users.py b/openerp/addons/base/res/res_users.py index e5c24bb7b19..43e5a34c02b 100644 --- a/openerp/addons/base/res/res_users.py +++ b/openerp/addons/base/res/res_users.py @@ -784,6 +784,21 @@ class groups_view(osv.osv): return True def get_application_groups(self, cr, uid, domain=None, context=None): + """ return the list of groups available to an user to generate virtual fields """ + + # TO REMOVE IN 9.0 + # verify if share column is present on the table + # can not be done with override as can not ensure the module share is loaded + # during an upgrade of another module (e.g. if has less dependencies than share) + # use ir.model.fields as _fields may not have been populated yet + got_share = self.pool['ir.model.fields'].search_count(cr, uid, [ + ('name', '=', 'share'), ('model', '=', 'res.groups')], context=context) + if got_share: + if domain is None: + domain = [] + # remove non-shared groups in SQL as 'share' may not be in _fields + cr.execute("SELECT id FROM res_groups WHERE share IS true") + domain.append(('id', 'not in', [gid for (gid,) in cr.fetchall()])) return self.search(cr, uid, domain or []) def get_groups_by_application(self, cr, uid, context=None):