Hello,
I have a field named "field1", that field should be not editable by user who has group named "Bloc fields" checked.
My test code is below:
1/file.xml
<record id="res_partner_form_update" model="ir.ui.view">
<field name="name">res.partner.form.update</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="groups_id" eval="[(4,ref('custom_module.bloc_fields'))]"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='user_id']" position="after">
<field name="field1"/>
</xpath>
</field>
</record>
2/security.xml
<record id="bloc_fields" model="res.groups">
<field name="name">Bloc fields</field>
<field name="comment">Enable/Disable fields</field>
</record>
3/ir.model.access.csv
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_res_partner_bloc_fields","res_partner bloc_fields","base.model_res_partner","bloc_fields",1,0,0,0
Result:
the field "field1" is gone, it is no longer visible but when i comment
<!-- <field name="groups_id" eval="[(4,ref('custom_module.bloc_fields'))]"/> --> it will be displayed
Please refer and try this :
https://www.odoo.com/forum/help-1/question/make-field-readonly-based-on-group-58921