Skip to Content
Menu
This question has been flagged
2 Replies
17079 Rodiniai

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

Portretas
Atmesti
Autorius Best Answer

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

Portretas
Atmesti

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

Best Answer

nice post.


Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
0
gruod. 19
6295
1
rugp. 23
2034
0
bal. 21
3267
1
liep. 19
7017
6
liep. 24
45715