How to Show Selection Field as Radio in Odoo

A selection field in Odoo is a drop-down list of options that users can choose from. When creating or editing a record, the selection field will be displayed as a list of dropdown buttons.

In some cases, if we need to render it as a radio widget, here is how to do it:

class TaxInvoiceExport(models.TransientModel):
    _name = ''
    _description = 'Tax Invoice Export'

    invoice_type = fields.Selection(string='Type', selection=[('invoice', 'Invoice'), ('bill', 'Vendor Bill')], default="invoice")

In view, use widget=”radio”

<record model="ir.ui.view" id="tax_invoice_export_form_view">
    <field name="name"></field>
    <field name="model"></field>
    <field name="arch" type="xml">
        <form string="Invoices">
                <field name="invoice_type" widget="radio"/>
                <button name="any_method_here" type="object" string="Export" class="oe_highlight"/>
                <button special="cancel" string="Cancel"/>
Scroll to Top

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.