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

i have a radio widget, i wanted it as a required field but the `required=True` is not working here.. 
any solution for this? 
vendor_from = fields.Selection([('user', 'User'), ('vendor', 'Vendor')], string="Vendor From")

形象
丢弃
最佳答案

Hello Ashutosh

`required=True` should work here in python field declaration.

Alternatively, you can write `required='"1"` in XML file for that field. Try this one it will solve your issue.


Thank you!

形象
丢弃
编写者

thank you :)

最佳答案

Hi,

The required parameter works with the fields when you add it in python field definition or XML code. But, it doesn't work when we use a radio widget for the selection field. If you need to make it required, then you have to provide a default value in the definition. Once you give a default value, it will be there and the only option for the user will be to change it and there will be no option to remove it like the normal dropdown option. Hence the field can be used as a required field. 

For example:

vendor_from = fields.Selection([('user', 'User'), ('vendor', 'Vendor')],
string="Vendor From", default='user')

Regards

形象
丢弃
编写者

thank you :)

相关帖文 回复 查看 活动
1
6月 25
1690
3
7月 25
3318
1
5月 25
1456
1
5月 25
1722
4
5月 25
2863