Odoo Help


How create a check box field in custom module

on 12/10/15, 6:30 PM 2,055 views

In Odoo 9:

i need create a field like check boxes:

what is your favorite color?  ☐ Blue  ☐Pink  ☐Yellow <--The user only can choice one favorite color, if the user select  ☐Blue then the  ☐Pink or  ☐Yellow field can not be selected, if the user select  ☐Pink, then  ☐Blue or  ☐Yellow can not be selected....

any idea how to create this type of field and function...

Axel Mendoza
On 12/10/15, 8:30 PM


You could create boolean fields for every color and put those rules in the view definition, like:

from openerp import models, fields, api

class module_example(models.Model):

_name = 'module.example'

blue = fields.Boolean('Blue')

pink = fields.Boolean('Pink')

yellow = fields.Boolean('Yellow')

and in the xml:

<record id="module_example_form" model="ir.ui.view">

<field name="name">myquality list</field>

<field name="model">myquality.myquality</field>

<field name="arch" type="xml">



<field name="blue" attrs="{'invisible': [('pink','=',True),('yellow','=',True)]}"/>

<field name="pink" attrs="{'invisible': [('blue','=',True),('yellow','=',True)]}"/>

<field name="yellow" attrs="{'invisible': [('pink','=',True),('blue','=',True)]}"/>





About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 12/10/15, 6:30 PM
Seen: 2055 times
Last updated: 12/13/15, 9:51 PM