OpenERP 7 How to give users access to custom module in OpenERP 7?

MJ X picture MJ X · Mar 13, 2014 · Viewed 7.8k times · Source

I have developed a custom Module in OpenERP 7, My administrator user can only see this module.

1-How can I give access to normal users to my custom modules?

2-What are the steps to solve this problem.

Please give a detailed example.

Answer

Bhavesh Odedra picture Bhavesh Odedra · Mar 20, 2014

Create a one Security folder which has below two files. For example,

  • test_security.xml and
  • ir.model.access.csv

security/test_security.xml file

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data noupdate="0">
        <record model="ir.module.category" id="module_category_name_test">
            <field name="name">Management</field> 
            <field name="sequence">7</field>
        </record>

        <record id="group_name_test_user" model="res.groups">
            <field name="name">User</field>
            <field name="category_id" ref="module_category_name_test"/>
            <field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
        </record>

        <record id="group_name_test_manager" model="res.groups">
            <field name="name">Manager</field>
            <field name="category_id" ref="module_category_name_test"/>
            <field name="implied_ids" eval="[(4, ref('group_name_test_user'))]"/>
            <field name="users" eval="[(4, ref('base.user_root'))]"/>
        </record>
    </data>
</openerp>

After do this Management Option show with two selection value like User and Manager in setting => Users => Access Rights => Application

Now turn for security/ir.model.access.csv

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
unique_id, test.name, model_test_name, group_name_test_user, 1,1,0,0
unique_id, test.name, model_test_name, group_name_test_manager, 1,1,1,1

test.name is a table name.

Example of csv file, how to create? Where

  • Fields => Value => Description

  • id => access_testing_for_user => id must be unique.

  • name => testing.for.user => name is given as we want.

  • model_id:id => model_test_name => model_id:id is given like model_our_class_name.

  • group_id:id => group_name_test_user => group_id:id is xml id of above we create like for User and Manager.

  • perm_read => 1 for True and 0 for False for read record.

  • perm_write => 1 for True and 0 for False for write record.

  • perm_create => 1 for True and 0 for False for create record.

  • perm_unlink => 1 for True and 0 for False for delete record.

NOTE

These two files .xml and .csv must be listed in __openerp__.py as other view files are given.