Skip to Content
Menú
This question has been flagged
1 Respondre
4304 Vistes

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


Avatar
Descartar

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

Best Answer

 Hi, 

In XML

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

OR 

In PY
test_field = fields.Char(string="Test Field",readonly=True)
Avatar
Descartar

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 Respostes Vistes Activitat
1
d’oct. 24
1542
4
de maig 24
12616
1
d’abr. 24
3257
0
de nov. 23
1997
1
de set. 23
2088