Search code examples
odooodoo-9odoo-10odoo-view

How to make dropdown for groups instead of checkboxes in Odoo?


I have made some groups A,B,C,D through GUI in Odoo v10. These groups are shown as check-boxes on the user page.

I want that instead of these check-boxes a dropdown must be shown so that user can be assigned to only a single group i.e. a user can only be in one of the A,B,C,D groups.

How can i do this??


Solution

  • I've found something that will clear how drop-downs are made and how check boxes are made. This is through code not from GUI as i am still finding a solution for it.

    So, drop-downs are made when each group in a category inherits some other group in same category in hierarchical manner.

    So, when i wrote the following code, check-boxes were made.

    <record id='group_category' model='ir.module.category'>
       <field name='name'>Category name</field>
    </record>
    
    <record id="group_a" model="res.groups">
        <field name="name">A</field>
        <field name="category_id" ref="group_category"/>
    </record>
    
    <record id="group_b" model="res.groups">
        <field name="name">B</field>
        <field name="category_id" ref="group_category"/>
    </record>
    
    <record id="group_c" model="res.groups">
        <field name="name">C</field>
        <field name="category_id" ref="group_category"/>
    </record>
    

    But when i wrote the following code in which one group inherits the other in a hierarchical way, drop-down was made

    <record id='group_category' model='ir.module.category'>
       <field name='name'>Category name</field>
    </record>
    
    <record id="group_a" model="res.groups">
        <field name="name">A</field>
        <field name="category_id" ref="group_category"/>
    </record>
    
    <record id="group_b" model="res.groups">
        <field name="name">B</field>
        <field name="category_id" ref="group_category"/>
        <field name="implied_ids" eval="[(4, ref('module_name.group_a'))]"/>
    </record>
    
    <record id="group_c" model="res.groups">
        <field name="name">C</field>
        <field name="category_id" ref="group_category"/>
        <field name="implied_ids" eval="[(4, ref('module_name.group_b'))]"/>
    </record>
    

    so, this was the case when i did it. Still finding a way to do it through GUI.