Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odpovědi
7358 Zobrazení

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

No errors but it does not work.

Avatar
Zrušit
Nejlepší odpověď

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
Zrušit
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)]})

Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
úno 25
1310
0
led 25
1134
1
pro 24
1457
1
pro 23
1483
1
čvn 22
5589