Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
17125 Widoki

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

Awatar
Odrzuć
Autor Najlepsza odpowiedź

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

Awatar
Odrzuć

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

Najlepsza odpowiedź

nice post.


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
gru 19
6339
1
sie 23
2065
0
kwi 21
3302
1
lip 19
7044
6
lip 24
45841