odooopenerp-8

Add Multiselect dropdown in Odoo module


I want to add a multiselect dropdown in Odoo module Field name will be Weekly Holiday which will be use to select multiple days of week

Below python is code i tried. 'weeklyholiday': fields.selection([('Sunday', 'Sunday'), ('Monday', 'Monday'), ('Tuesday', 'Tuesday'),('Wednesday', 'Wednesday'),], "Weekly Holiday"),


Solution

  • AFAIK you can't have multiselection, unless you use some external field type. I suggest you instead to change your field in a many2many:

    weeklyholiday = fields.Many2many('weekday')
    

    with the following declaration in the view, you should be able to accomplish your need.

    <field name="weeklyholiday" widget="many2many_tags" options="{'no_create_edit':'1'}"/>