Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
17225 Tampilan

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

Avatar
Buang
Penulis Jawaban Terbai

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
Buang

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

Jawaban Terbai

nice post.


Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
0
Des 19
6458
1
Agu 23
2172
0
Apr 21
3367
1
Jul 19
7170
6
Jul 24
46189