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

How to set an attribute of a field like this self._fields['name'].readonly=True ?

No errors but it does not work.

아바타
취소
베스트 답변

Do you wish to make the field readonly? In this case you either define it on the just created field (something like: your_field = fields.Char(string='My string', readonly=True)

or in XML by doing this:

<field name="your_field" readonly="1"/>

아바타
취소
작성자

I need to be able to write into a field and later on some conditions make the field readonly. As I know it can be done with 'state' field in this way:

my_field=field.Char(readonly=True, states={'draft': [('readonly', False)]})

베스트 답변

Set the readonly in python code, like this:
my_field = fields.Char(readonly=True)


or in a xml, like this:
<field name="my_field" readonly="1"/>

아바타
취소
관련 게시물 답글 화면 활동
0
2월 25
1382
0
1월 25
1166
1
12월 24
1524
1
12월 23
1509
1
6월 22
5676