5

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.

MJ X
  • 8,506
  • 12
  • 74
  • 99

1 Answers1

16

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.

Bhavesh Odedra
  • 10,990
  • 12
  • 33
  • 58
  • Thanks for answer I followed your steps, but I didn't see access right drop down to give normal users to my custom developed module, could you please explain more than this because I am new to OpenERP development. – MJ X Mar 20 '14 at 22:19
  • have you mention `test_security.xml` file `__openerp__` file ? – Bhavesh Odedra Mar 21 '14 at 05:14
  • 1
    Dear Odedra please could you explain how to create this csv file, and what are the standards to implement and what are those codes inside and how to create those codes. –  Mar 23 '14 at 19:34
  • in `.xml file`, we create a one menu in above path given e.g. Access Rights => Application. `.xml file` is used for the menu and which has two selection value e.g. User and Manager. If you select `User`, as per User rights given in csv file are applied on it. And for same 'Manager'. For particular menu rights we use `.xml id` in our `view.xml` file. And one important thing, these two files must be listed in the `__openerp__.py` as we give `other view files`. – Bhavesh Odedra Mar 24 '14 at 06:16
  • Hello downvoter, you may welcome for give suggestion while give any answer for down vote, please add comment the reason. Because it will help a lot for improving the content. Thanks – Bhavesh Odedra Feb 10 '15 at 04:57
  • Hi Odedra, can you suggest good learning material on general Odoo and security? – Alexander Suraphel Jul 11 '15 at 12:13
  • hi @AlexanderSuraphel, you may checkout this slideshare http://www.slideshare.net/openobject/openerp-security-in-openerp and but I always not found any powerful documentation of security in OpenERP/Odoo. One another found http://openerp-server.readthedocs.org/en/latest/04_security.html – Bhavesh Odedra Jul 12 '15 at 15:43