Skip to Content
Menu
This question has been flagged
1 Reply
3880 Views

Hi All,

I am looking to add a group to a custom module so that I can control access to various menus. I modeled my code after the purchases module, but am not seeing the group under settings. Is there any documentation on how to code groups into modules? Here is the code I have now:

ec_purchases_security.xml:

<?xml version="1.0" encoding="utf-8"?>

<openerp>

<data noupdate="0">

 

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

        <field name="name">Electrochem Purchasing</field>

        <field name="category_id" ref="base.module_category_purchase_management"/>

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

    </record>

</data>

</openerp>

ir.model.access.csv:

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

access_purchase_order,purchase.order,model_purchase_order,group_ec_purchase,1,1,1,1

Any idea why this isn't loading? I'm not getting any error messages. I was sure to add 'ir.model.access.csv' and 'ec_purchases_security.xml' to the 'data' field in __openerp__.py

Avatar
Discard
Best Answer

Hello!

the most easy way that i found to do this is the next:

(+Tip: in your module _manifest_.py   i put firs the security.xml and then after the ir.model.access.csv , im not sure about if this changes something)


in security/security.xml add the groups that later gonna be usen in access.csv like this way


odoo>

​record id="group_identifier1" model="res.groups">
​field name="name">Group Name
​field name="comment">Description Permission Group
​/record>
​record id="group_identifier2" model="res.groups">
​field name="name">Group Name2
​field name="comment">Description2 Permission Group
​/record>
/odoo>


Then after in your file "ir.model.access.csv" can use in the "group_id" column your groups like this way

id1,name,model_id:id,your_module_name.group_identifier1,1,1,1,1
id2,name,model_id:id,your_module_name.group_identifier2,1,1,1,1


I hope be usefull for who needs. Regards!


Avatar
Discard