Odoo Help

Welcome!

This community 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.

0

How create a check box field in custom module

By
Carlos
on 12/10/15, 6:30 PM 1,214 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...

2

Axel Mendoza

--Axel Mendoza--
10238
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

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

@Carlos

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">

<form>

<group>

<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)]}"/>

</group>

</form>

</field>

</record>

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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