Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
7234 Lượt xem

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

No errors but it does not work.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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"/>

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Câu trả lời hay nhất

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"/>

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 2 25
1256
0
thg 1 25
1096
1
thg 12 24
1384
1
thg 12 23
1435
1
thg 6 22
5525