Skip to Content
Menu
This question has been flagged
1 Reply
2199 Views

Hello,
I added a selection field to my table to indicate the related entity is blocked. The first value should be an empty value, meaning 'not blocked'

blocked = fields.Selection(
string='Blocked',
selection=[(' ',' '), ('payment','Payment'), ('all','All')])

When I put this field on a page, the first value is displayed twice in the dropdown. If I capitalize the other 2 values, then all are displayed twice. It seems that both values in the tulip are displayed if they are the same?

How can I use the selection where the values in the tulip are the same? I'm using ODOO 17.

Thx in advance

Andy

Avatar
Discard
Best Answer

Hi,

You can achieve this by keeping the two selections only and making them not required with no default value, the user will have to actively select one of the options.

This way, the user can choose between 'Payment', 'All', or leave the field blank ('Not Blocked').

blocked = fields.Selection(
    string='Blocked',
    selection=[('payment', 'Payment'), ('all', 'All')],
)

Hope this will help you

Thanks

Avatar
Discard
Author

Thanks, works like a charm!
Andy