跳至内容
菜单
此问题已终结
2 回复
17077 查看

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
6295
1
8月 23
2034
0
4月 21
3261
1
7月 19
7017
6
7月 24
45713