Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
3 Відповіді
7311 Переглядів

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

No errors but it does not work.

Аватар
Відмінити
Найкраща відповідь

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

Аватар
Відмінити
Автор

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

Найкраща відповідь

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

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
0
лют. 25
1297
0
січ. 25
1115
Field service upgrade Вирішено
1
груд. 24
1436
1
груд. 23
1480
1
черв. 22
5560