Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
17055 Vizualizări

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

Imagine profil
Abandonează
Autor Cel mai bun răspuns

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)]}"/>

Imagine profil
Abandonează

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

Cel mai bun răspuns

nice post.


Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
0
dec. 19
6292
1
aug. 23
2032
0
apr. 21
3259
1
iul. 19
7014
6
iul. 24
45683