Hi,
I want to set the readonly attribute to true on a specific field but it remains editable
This is my code:
@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False,
submenu=False):
res = super(ResPartner, self).fields_view_get(
view_id=view_id, view_type=view_type, toolbar=toolbar,
submenu=submenu,
)
if view_type == 'form':
user = self.env['res.users'].search([('id', '=', self.env.context.get('uid', False))])
if not user[0].return_percentage_modify:
res_xml = etree.XML(res['arch'])
res_fields = res_xml.xpath("//field[@name='porcentaje_devolucion']")
if res_fields:
res_field = res_fields[0]
print('Entra res_field')
res_field.set('attrs',"{'readonly':True}")
res['arch'] = etree.tostring(res_xml)
return res