コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
17067 ビュー

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.


アバター
破棄
関連投稿 返信 ビュー 活動
0
12月 19
6294
1
8月 23
2033
0
4月 21
3259
1
7月 19
7016
6
7月 24
45700