Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
17056 มุมมอง

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

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง

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

คำตอบที่ดีที่สุด

nice post.


อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ธ.ค. 19
6293
Field editing after create a form แก้ไขแล้ว
1
ส.ค. 23
2032
0
เม.ย. 21
3259
1
ก.ค. 19
7015
6
ก.ค. 24
45690