Skip to Content
Menu
This question has been flagged
3197 Views

Hi everyone,

I'm trying to make a field readonly for a certain group of user in a custom module. For this I've created custom groups and I defined access rules. After looking on the forum the best way to make my field readonly seems to be this way :


<field name="groups_id" eval="[(6, 0, [ref('my_custom_module.admins') ])]" />
(...)
<field name="my_field" position="attributes">
<attribute name="readonly">0</attribute>

<field name="groups_id" eval="[(6, 0, [ref('my_custom_module.users') ])]" />
(...)
<field name="my_field" position="attributes">
<attribute name="readonly">1</attribute>

But it raises this error  :
ParseError: ""External ID not found in the system: my_custom_module.admins" while evaluating"[(6, 0, [ref('my_custom_module.admins') ])]""

I've created my custom groups in the "groups" menu so I dont know  where to look under which name they're stored in the database. However I've the same problem with "base.group_user" so I dont know where the problem comes from.

Thanks you in advance for any help.

Avatar
Discard

Hi, have you tried something like

<field name="your field" attrs="{'readonly':[('group','=',yourGroup)]}"/>

or maybe

<field name="your field" attrs="{'readonly':[(uid.groups,'=',yourGroup)]}"/>

I'm not really sure...

By the way I have some similar problems, let us know if you find a solution !

Author

Hi,

I've tried your solution in several ways but it doesn't work.

After some research I read that since Odoo 7 we cant use group attributes on fields.

To solve this issue I created two different views, one for user and one for admins, with specific rights.