Help

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

how to set radio widget as a required field?

Avatar
odoo
Avatar
Discard
2 Answers
0
Avatar
odoo
Best Answer

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!

1 Comment
Avatar
Discard
Avatar
odoo
-

thank you :)

0
Avatar
odoo
Best Answer

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

1 Comment
Avatar
Discard
Avatar
odoo
-

thank you :)