[FIX] base,share: error in_group_xx on user form
res.users form contains virtual fields in_group_ID to be added in res.groups. Groups with boolean share=True (added by share module) must not be displayed in the form and should not be modifiable through the user interface. However, if a module adding/modifying a res.group is earlier in the dependency graph than 'share' (e.g. only depends from 'base'), the update of the user view is done before share is loaded and the overrride of 'get_application_groups' is never executed. As we can not guarantee that the module is share loaded, put the logic of hidding the module in base instead of share. This workaround is quite hacky but is necessary in stable version. Better fix in 9.0 at cf63d4d Fixes #6324 Fixes #5820
This commit is contained in:
parent
93d4db9d1e
commit
44248a07a5
|
@ -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:
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue