Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
8214 Vistas

I am creating a custom module in Odoo for a faculty and y need to create 3 roles (groups): students, professors and admins. An user cannot have 2 roles at the same time, so it could only be either a teacher, a professor or an admin. I have defined the permisions in the following code. But for selecting those permissions, Odoo creates a view with checkboxes, where you can chose 2 or more roles at the same time, instead of a selection field (dropdown), I dont want that. How can I force Odoo to create a dropdown for the selection of those roles, so I can only select one


<record model="ir.module.category" id="module_category_faculty">
    <field name="name">Faculty</field>
    <field name="description">Faculty Roles</field>
    <field name="sequence">45</field>
</record>

<record id="group_faculty_student" model="res.groups">
    <field name="name">Student</field>
    <field name="category_id" ref="module_category_faculty"/>
</record>

<record id="group_faculty_professor" model="res.groups">
    <field name="name">Professor</field>
    <field name="category_id" ref="module_category_faculty"/>
</record>

<record id="group_faculty_admin" model="res.groups">
    <field name="name">Admin</field>
    <field name="category_id" ref="module_category_faculty"/>
</record>
Avatar
Descartar
Mejor respuesta

Hi Ernesto Ruiz,

<record model="ir.module.category" id="college_management">

        <field name="name">College Management</field>

    </record>

    <record id="group_student" model="res.groups">

        <field name="name">Student</field>

        <field name="category_id" ref="college_management"/>

        <field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>

    </record>

    <record id="group_professor" model="res.groups">

        <field name="name">Professor</field>

        <field name="category_id" ref="college_management"/>

        <field name="implied_ids" eval="[(4, ref('base.group_user')),(4, ref('group_student'))]"/>

    </record>

    <record id="group_admin" model="res.groups">

        <field name="name">Admin</field>

        <field name="category_id" ref="college_management"/>

        <field name="implied_ids" eval="[(4, ref('base.group_user')),(4, ref('group_student'))]"/>

    </record>

Thank You!

Regards,




Email:      odoo@aktivsoftware.com  

Skype: kalpeshmaheshwari

   

Avatar
Descartar

Thanks this solution help me !

Hello !
I don't think your solution would work. In order to have a droplist, you have to have a hiearchy in the implied_ids. If group_professor and group_admin both have the same implied_ids, it'll still show as checkboxes.

The correct way would be:
<record model="ir.module.category" id="college_management">
<field name="name">College Management</field>
</record>
<record id="group_student" model="res.groups">
<field name="name">Student</field>
<field name="category_id" ref="college_management"/>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
</record>
<record id="group_professor" model="res.groups">
<field name="name">Professor</field>
<field name="category_id" ref="college_management"/>
<field name="implied_ids" eval="[(4, ref('group_student'))]"/>
</record>
<record id="group_admin" model="res.groups">
<field name="name">Admin</field>
<field name="category_id" ref="college_management"/>
<field name="implied_ids" eval="[(4, ref('group_professor'))]"/>
</record>

Publicaciones relacionadas Respuestas Vistas Actividad
1
oct 24
864
0
jun 24
774
0
nov 23
1211
1
nov 23
2995
1
jun 23
1829