Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
17081 Представления

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
6297
1
авг. 23
2034
0
апр. 21
3271
1
июл. 19
7017
6
июл. 24
45719