Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
3 Răspunsuri
7333 Vizualizări

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

No errors but it does not work.

Imagine profil
Abandonează
Cel mai bun răspuns

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"/>

Imagine profil
Abandonează
Autor

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)]})

Cel mai bun răspuns

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"/>

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
0
feb. 25
1306
0
ian. 25
1129
1
dec. 24
1449
1
dec. 23
1480
1
iun. 22
5575