Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
17068 Переглядів

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
6294
1
серп. 23
2033
0
квіт. 21
3259
1
лип. 19
7016
6
лип. 24
45700