Skip to Content
Menu
This question has been flagged
3 Replies
3083 Views

Hi,

I have this code below which I want this field to be invisible if the user login is not accounting. I tried res, base but it didn't work. 

<field name="account_charge_id" style="width: 30%" attrs="{'invisible':[('????', '!=', 'Accountant')]}"/>
Avatar
Discard

Get current logged in user id in odoo: https://goo.gl/KzXLak

How to visible and invisible fields in odoo: https://goo.gl/BCxCpk

Best Answer

Hi William,

You should use "groups" instead:

<field name="account_charge_id" style="width: 30%" groups="account.group_account_user"/>

Regards,
Ivan

Avatar
Discard
Author

By the way, how to know the groups? where can we find this information "account.group_account_user"? I tried to check this in PostgreSQL DB, there is no much info about it.

You can view the user group ID by enable developer mode, after that go to the group record you wish to know the ID, click the bug icon in the header -> view metadata

You should see it

Author

Thank you.

Best Answer

Dear William,

Adding Group is suggested. Also possible by compute field.

def _compute_field_visibility(self):
# block

field_visibility = fields.Boolean(compute='_compute_field_visibility')

Regards


Global Creative Concepts Tech Co Ltd.


Avatar
Discard
Author

We'll I tried to do this also but I don't know the exact field to be used in order to create a logic that triggers the boolean field.

I tried like this:

if res.group_id.name in ['Accountant', 'Manager', 'Administrator']:

field_visibility = true

else:

field_visibility = false

It had an error because they don't recognize "res".

Related Posts Replies Views Activity
1
Aug 24
260
1
Jul 24
555
2
Aug 24
2506
1
Sep 24
552
1
Jan 24
340