Good morning,
I have many2one field, and i would like to show it only to users who are admin.
So i have created a function which return the groupe name of connected user :
@api.multi
def user_group(self,cr,uid,ids,context):
user = self.env['res.users'].browse(self.env.uid)
if user.has_group('gestion_parcelles.group_ferme_admin'):
return('admin')
elif user.has_group('gestion_parcelles.group_ferme_manage'):
return ('manager')
elif user.has_group('gestion_parcelles.group_ferme_user'):
return ('user')
Then i have used it to filter my field :
approved_by = fields.Many2one('res.users', 'Affecter à', domain="[('user_group()', '=', 'admin')]")
But in the execution i get an error; can you show me how i should use thid function in my domaine filter.
Thank you @CV, and how then i will call: " def fields_view_get " function ?
@cv, can you help me about this erreur please
NameError: global name 'etree' is not defined
@cv i got also this erreur :
Uncaught TypeError: Cannot read property 'arch' of null