1
votes

I'm working with odoo 10 on windows. I've created a new custom module now I want to add some menus of my costum modules to certains users.

I'm new to odoo so my question is can I do that by creating group, associate the menus to my group then add the users to the group (I trid that but it did not work, when I log in with the user I find nothing). I've search on the web and I found that I need to creat my groups trough ir.model.access.csv (security folder) with this : id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_testmod_test,access_testmod_test,model_testmod_test,,1,1,1,1. Unfourtunately, I did not quite understand how can I do that and what should I write in some fields. So can someone please give me a good tutorial that I can use, with examples, witch shows me how to create diffrents groups and adde users to it and add also some of the menus of my custom module to it.

Thank you.

2
I too beginner in odoo the above link, this link helped me to create access rules and security, groups, stackoverflow.com/questions/22368935/…ShivaGuntuku

2 Answers

1
votes

so I tried this code but it did not work with me maybe I did it wrong here what I did : I created a file securuty.xml in my security folder with contain the following

<?xml version="1.0" encoding="utf-8"?>
<odoo>
   <data noupdate="0">
       <!-- Creating a Group Category -->        
       <record id="evaluation_subj" model="ir.module.category">
           <field name="name">evaluation subjective</field>
           <field name="sequence">1</field>
       </record>
       <!-- Adding a Group to the Group Category -->
       <record id="group_eval_subj" model="res.groups">
           <field name="name">Groupe Evaluation Subjective</field>
           <field name="evaluation_subj" ref="evaluation subjective"/>
           <!-- Adding Rights of existing Groups -->
           <field name="implied_ids"
                  eval="[(4, ref('base.group_system')), (4,ref('base.group_sale_manager'))]"/>
       </record>
    </data>
</odoo>

Then in the file pnc_menus.xml (I have a file called pnc_menus.xml where I created all of my menus) I added the groups field to this menu:

<menuitem name="Parties Prenantes" id="pnc_evaluation_stakeholders" action="pncevaluation_partieprenante" parent="pnc_documents" sequence="40" groups="base.group_system"/> Then in csv file of my security folder I added this : id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink eval_group,groupe_evaluation,pnc_evaluation_stakeholders,group_eval_subj,1,1,1,1 When I updated my module I have an error saying "csv file could not be proccessed"

0
votes

Creating group category and group

security/security.xml

<?xml version="1.0" encoding="utf-8"?>
    <openerp>
       <data noupdate="0">
           <!-- Creating a Group Category -->        
           <record id="category_name" model="ir.module.category">
               <field name="name">Name</field>
               <field name="sequence">1</field>
           </record>
           <!-- Adding a Group to the Group Category -->
           <record id="group_name" model="res.groups">
               <field name="name">Group Name</field>
               <field name="category_id" ref="category_name"/>
               <!-- Adding Rights of existing Groups -->
               <field name="implied_ids"
                      eval="[(4, ref('base.group_system')), (4,ref('base.group_sale_manager'))]"/>
           </record>
        </data>
    </openerp>

Adding a group to an existing menu (base.group_system)

<menuitem name="Name" id="id_name" parent="module.menu_id" action="module.action_id" 
groups="base.group_system"/>

security/ir.model.access.csv

Give your group access to your model

access_anything,classname,model_classname,group_id,1,1,1,1

for example (base. is added because model_ir_property is not from the own module)

access_ir_property1,ir_property,base.model_ir_property,your_new_group_id,1,1,1,1

Go to Settings->Groups, select your new group, press "Edit" and add users at page "Users".