Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
4309 Weergaven

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
Annuleer

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

Beste antwoord

 Hi, 

In XML

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

OR 

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

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!

Gerelateerde posts Antwoorden Weergaven Activiteit
1
okt. 24
1592
4
mei 24
12623
1
apr. 24
3267
0
nov. 23
2014
1
sep. 23
2101