Odoo Help


How to create a checkbox field in odoo 8?

on 3/1/16, 1:56 AM 4,293 views

Here is my declared field in account_voucher.py file,

'type':fields.selection([('dr','Debit'),('cr','Credit')], 'Dr/Cr')

In the view(xml file),

 <field name="type" widget="radio" options='{"horizontal": 1}' />

Right now it is radio button I want to change it to checkbox  

On 3/1/16, 4:43 AM

To explain this and make it clearer,this type of checkbox that you want to add works only with the manytomany fields,and this field will display one checkbox for each record existing in the model targeted by the relation, according to the given domain if one is specified.Checked records will be added to the relation 

and There’s no way to use this widget to create new items

<field name="field_name" widget="many2many_checkboxes"/>

and as it seems you declared that field as selection filed so you have two options the first is to follow the first method of boolean type or to do like Ankit H had said

you could create boolean fields for each selection and put them in your view definition like this in the .py file:

_columns = {

'dr': fields.boolean('Debit'),
'cr': fields.boolean('Credit'),

and in the xml:

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



<field name="dr" attrs="{'invisible': [('cr','=',True)]}"/>

<field name="cr" attrs="{'invisible': [('dr','=',True)]}"/>




hope it helps you

I dont want to alter python code, I just to want to acheive it just by using xml file, So is their any widget for checkbox?

on 3/1/16, 4:55 AM

hope it helps, modified my answer

on 3/1/16, 5:46 AM
On 8/24/16, 2:46 AM


Just create given below in .py file

          'blue' : fields.boolean('Blue'),

         'pink' : fields.boolean('Pink'),

then xml file do this,

         <field name="blue" type="checkbox" />

       <field name="pink" type="checkbox" />

Try this it's worked for me


Ankit H Gandhi(AHG)

--Ankit H Gandhi(AHG)--

| 6 5 6
Baroda, India
--Ankit H Gandhi(AHG)--

Learning Python..

Ankit H Gandhi(AHG)
On 3/1/16, 4:47 AM

Hello Bhanukiran,

You could use widget like many2many_checkboxes.

But your field type must be many2many

For example

in .py file.

class type_type(osv.Model):

_name = 'type.type'

_columns = {

'name': fields.char('Name')


class your_class_name(osv.Model):

_name = 'your.class.name'

_columns = {

'type_checkbox': fields.many2many('type.type', 'type_help_rel', 'type_id', 'help_id', 'Type')


in xml file.

<field name="type_checkbox" widget="many2many_checkboxes"/>

Hope this help for you.


Ankit H Gandhi.

On 8/24/16, 5:43 AM

hai arun,

  It  works thank you.

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: 3/1/16, 1:56 AM
Seen: 4293 times
Last updated: 8/24/16, 5:43 AM