İçereği Atla
Menü
Bu soru işaretlendi
3 Cevaplar
7274 Görünümler

How to set an attribute of a field like this self._fields['name'].readonly=True ?

No errors but it does not work.

Avatar
Vazgeç
En İyi Yanıt

Do you wish to make the field readonly? In this case you either define it on the just created field (something like: your_field = fields.Char(string='My string', readonly=True)

or in XML by doing this:

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

Avatar
Vazgeç
Üretici

I need to be able to write into a field and later on some conditions make the field readonly. As I know it can be done with 'state' field in this way:

my_field=field.Char(readonly=True, states={'draft': [('readonly', False)]})

En İyi Yanıt

Set the readonly in python code, like this:
my_field = fields.Char(readonly=True)


or in a xml, like this:
<field name="my_field" readonly="1"/>

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
0
Şub 25
1287
0
Oca 25
1106
1
Ara 24
1418
1
Ara 23
1460
1
Haz 22
5547