コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
4356 ビュー

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!

関連投稿 返信 ビュー 活動
1
10月 24
2680
4
5月 24
12780
1
4月 24
3408
0
11月 23
2073
1
9月 23
2207