콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
17179 화면

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
6397
1
8월 23
2142
0
4월 21
3314
1
7월 19
7118
6
7월 24
45965