In previous version (15.0 and below) we are able to inherit a views and set the attributes to certain fields based on group assigned using groups_id.
<field name="groups_id" eval="[(4, ref('module_name.group_name'))]"/>
We can later change a certain attributes to a fields, for example using XPath this way:
<xpath expr="//field[@name='field_name']" position="attributes">
<attribute name="readonly">1</attribute>
</xpath>
The field_name
will later become readonly based group on which user is assigned into module_name.group_name
. However, I don't quite understand how to do it in Odoo 16. The docs stated that we are able to define group to user this way
<field name="field_name" groups="module_name.group_name" readonly="1"/>
This works only for a custom field that we created. When i applied using XPath, especially when inheriting available views and doing attributes to a created field, it's either will makes it readonly to all users or not working at all. Here's my attempt to apply an attributes to employee_id in attendance module :
<xpath expr="//field[@name='employee_id']" position="attributes">
<t groups="check_in_location.group_attendance_basic">
<field name="employee_id" readonly="1"/>
</t>
</xpath>
This, however doesn't change anything. the check_in_location.group_attendance_basic
is a separate group that i created and it don't inherit all other default group from attendance.
How is it possible to apply attributes to field based on a group? in this case, a readonly
?
Thanks
Edit : Using this is working, but other group cannot see that field
<xpath expr="//field[@name='employee_id']" position="attributes">
<attribute name="groups">check_in_location.group_attendance_basic</attribute>
<attribute name="readonly">1</attribute>
</xpath>