Ir al contenido
Menú
Se marcó esta pregunta
2 Respuestas
17145 Vistas

In a form view, what way would you have a field only be editable when the object is crated and not editable afterwards.
 

Avatar
Descartar
Autor Mejor respuesta

An object on create will not have an id. Afterwards, it will always have one.

Taking advantage of this behaviour, the id can be used to set the readonly attribute.

<field name="id" invisible="1"/>

<field name="uneditable_field" attrs="{'readonly': [('id', '!=', False)]}"/>

Avatar
Descartar

Well done. I was stuggled with this. I didn't think to add the "id" field as invisible to make it available in the domain. Thanks for sharing! J

Mejor respuesta

nice post.


Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
0
dic 19
6351
1
ago 23
2069
0
abr 21
3303
1
jul 19
7065
6
jul 24
45864