I was trying to make all fields in a form view read-only in odoov10. Is there any python method through I can get all the form view fields and change its attribute to readonly="True"?
I don't know if it's a correct method, but there is a workaroud you can use:
@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
res = super(Lead, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)
if view_type == 'form':
res['arch'] = self.fields_view_get_address(res['arch'])
# res contains the view form, and you can manipulate res string, as you desired.
return res
Alternatively you can disable edit option in the form view, by using:
<field ... edit="false" />