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

I am trying to make a field in my form view visible only in read mode. I'm using the following code:


models.py

test_field = fields.Char(string="Test Field")

view.xml

<field name="test_field" class="oe_read_only"/>

However, the field still shows in edit mode. I only want it to appear in read mode. What am I doing wrong?


Reference: https://stackoverflow.com/a/38238138


อวตาร
ละทิ้ง

"oe_read_only" works fine in v13 and v14 as well.

คำตอบที่ดีที่สุด

 Hi, 

In XML

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

OR 

In PY
test_field = fields.Char(string="Test Field",readonly=True)
อวตาร
ละทิ้ง

Hi,
If I am not wrong, this only prevent modification of the field on edit mode.
This works on odoo12
<field name="test_field" class="oe_read_only"/>
I don't know why it's not working for you on odoo13!

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ต.ค. 24
3285
4
พ.ค. 24
12902
1
เม.ย. 24
3497
0
พ.ย. 23
2163
Blank White Page After log in to Odoo13 แก้ไขแล้ว
1
ก.ย. 23
2340