This question has been flagged
2 Replies
4554 Views

Hi folks,

So, I have been playing with permissions in my system and have a question regarding groups. It is quite common for me to hide fields so that only members of certain groups can see the field. The code looks like this:

<field name="hidden_field" groups="group_account_admin" />

As you are aware, this code means that only members of the group "group_account_admin" can view the field "hidden_field".

What I would like to know is what the inverse of this might be? So, what I want to do is if you are a member of the group, show one thing, otherwise show something else.

Does anyone know how I might achieve this? I'm thinking something like the following:

<field name="hidden_field" groups="group_account_admin" />
<label string="You do not have access to this" groups!="group_account_admin" />

Many thanks,

-Alex

Avatar
Discard
Best Answer

I think in Odoo this feature is not available

Avatar
Discard
Best Answer

It's some time ago, however, it may be helpful to sombody. For my dialog (TransientModel) I created a helper field:


def _get_has_mygroup(self):
return self.env.user.has_group('mygroup')

has_mygroup = fields.Boolean(default=_get_has_mygroup)


Afterwards I use it for readonly or invisible conditions.

Avatar
Discard

Hello, This also based on group only