Odoo Help


Showing only users that belong to a specific group

Timo Talvitie, Vizucom Oy
on 12/13/13, 6:19 AM 1,216 views

I have a form with a many2one dropdown field for selecting a user. What would be the best way to have the dropdown list of the field show only users that belong to a specific group, for example Sales Managers?


Ankit H Gandhi(AHG)

--Ankit H Gandhi(AHG)--

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

Learning Python..

Ankit H Gandhi(AHG)
On 7/1/15, 6:22 AM

Dear Timo Talvitie,

 try this code may be used for you.

<field name="many2one_field" groups="base.group_sale_manager"/>


You should create security file and assign that group in many2one field.

If you dont know how to create security file then follow below step and hope you will get answer

  1. You have to create ir.model.access.csv in your module, I suggest you to create a security folder and put security related file there

  2. Like security/ir.model.access.csv and security/given_any_name_security.xml

  3. Change in openerp.py file like 'security/given_any_name_security.xml, 'security/ir.model.access.csv'

  4. Inside xml file you sholud create group like

    1. <?xml version="1.0" ?>


      <data noupdate="1">

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

      <field name="name">School</field>

      <field name="description">School</field>

      <field name="sequence">16</field>


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

      <field name="name">User</field>

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


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

      <field name="name">Manager</field>

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

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

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




  5. Inside csv file you should give the permission like

    1. id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink





  6. Now in your view file to add group in field like

    <field name="many2one_field" groups="module_name.group_id"/>

    here groups define the value of module_name.group_id that means

    group_id: group id which is define in security xml file


    <field name="hobby_id" groups="school_management.group_school_manager"/>

    Finally update the module

    Hope this code is usefully for you.

    Thanks & Regards

    Ankit H Gandhi

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

0 follower(s)


Asked: 12/13/13, 6:19 AM
Seen: 1216 times
Last updated: 7/1/15, 6:22 AM