Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
3 ตอบกลับ
7268 มุมมอง

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

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ก.พ. 25
1286
0
ม.ค. 25
1105
Field service upgrade แก้ไขแล้ว
1
ธ.ค. 24
1418
1
ธ.ค. 23
1460
1
มิ.ย. 22
5547