Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
17093 Zobrazení

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

Avatar
Zrušit
Autor Nejlepší odpověď

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
Zrušit

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

Nejlepší odpověď

nice post.


Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
pro 19
6313
1
srp 23
2047
0
dub 21
3293
1
čvc 19
7024
6
čvc 24
45773