This does not work
field name="price_unit" attrs={'readonly': [('groups_id', 'not in', [ref('purchase.group_purchase_manager')])]}
error
Field 'groups_id' used in attrs ({'readonly': [('groups_id', 'not in', [ref('purchase.group_purchase_manager')])]}) must be present in view but is missing.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Boekhouding
- Voorraad
- PoS
- Project
- MRP
Deze vraag is gerapporteerd
Hi,
If you are using odoo 15 or below, you can achieve this by creating a inherited view for this user group and setting readonly for the field from that view.
* Create new inherited view
* assign user group for the view
* xpath the field and make it readonly
Doing this, field will get readonly for the users in this group.
For more, see: https://www.youtube.com/watch?v=Fsp6lAPHz08
Thanks
Hi. This solution no longer works for V17. I get this error
Inherited view cannot have 'Groups' define on the record. Use 'groups' attributes inside the view definition
Any Ideas? Thanks.
I was able to figure it out. For anyone in my situation, I achieved this in odoo17 by first creating a new user group that inherited from existing user that can edit the field and created a new view like this.
<xpath expr="//sheet/notebook/page/field[2]/tree/field[@name='price_unit']" position="attributes">
<attribute name="groups">purchase.group_purchase_user</attribute>
</xpath>
<xpath expr="//sheet/notebook/page/field[2]/tree/field[@name='price_unit']" position="after">
<field name="price_unit"
readonly="1"
groups="new_module.new_group,!purchase.group_purchase_user"/>
</xpath>
Notice that I now have 2 price_unit fields.
I believe this works because since the new group inherits the existing group, we have to explicitly specify that the inherited group is not allowed to view this new price_unit field. Hence, !purchase.group_purchase_user
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
AanmeldenGerelateerde posts | Antwoorden | Weergaven | Activiteit | |
---|---|---|---|---|
|
1
feb. 24
|
2666 | ||
|
0
feb. 24
|
10 | ||
|
1
mrt. 15
|
4829 | ||
|
1
mrt. 25
|
1201 | ||
|
0
nov. 24
|
945 |