Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
17085 Visualizzazioni

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

Avatar
Abbandona
Autore Risposta migliore

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
Abbandona

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

Risposta migliore

nice post.


Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
dic 19
6301
1
ago 23
2037
0
apr 21
3278
1
lug 19
7017
6
lug 24
45734