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

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


Ảnh đại diện
Huỷ bỏ

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

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

 Hi, 

In XML

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

OR 

In PY
test_field = fields.Char(string="Test Field",readonly=True)
Ảnh đại diện
Huỷ bỏ

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!

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 10 24
2707
4
thg 5 24
12809
1
thg 4 24
3432
0
thg 11 23
2078
1
thg 9 23
2232