Hi everone,
I know the method to make the whole form view read-only always when the method is runned
but I need to insert a condition:
@api.model
def fields_view_get(self, view_id=None, view_type=False, toolbar=False, submenu=False):
res = super(SaleOrder, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar, submenu=submenu)
#we can not get any data related to the respective record
#so I can not insert the following condition:
# if self.status_invoice == 'invoiced':
doc = etree.XML(res['arch'])
if view_type == 'form':
for node in doc.xpath("//field"):
modifiers = simplejson.loads(node.get("modifiers"))
modifiers['readonly'] = True
node.set('modifiers', simplejson.dumps(modifiers))
res['arch'] = etree.tostring(doc)
return res
is there any way to extend 'attrs' via python?
... attrs['readonly'] += ('|',('invoice_status','=','invoiced'))