跳至内容
菜单
此问题已终结
3 回复
7450 查看

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

形象
丢弃
相关帖文 回复 查看 活动
0
2月 25
1445
0
1月 25
1211
1
12月 24
1589
1
12月 23
1538
1
6月 22
5765