تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
3657 أدوات العرض

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
يونيو 25
1682
3
يوليو 25
3308
1
مايو 25
1452
1
مايو 25
1714
4
مايو 25
2859