2
votes

I have created a new module in openerp now I want to give security for the module for that I have created a folder named "security" inside my module folder and created a xml file and ir.model.access.csv file in it.My aim is I want to create two roles for my module one is manager and other is user. for that I have added the below code in the xml file

<record id="group_mat_mgmt_user" model="res.groups">
        <field name="name">User</field>
        <field name="category_id" ref="base.module_category_mat_mgmt"/>
        <field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
    </record>
    <record id="group_mat_mgmt_manager" model="res.groups">
        <field name="name">Manager</field>
        <field name="category_id" ref="base.module_category_mat_mgmt"/>
        <field name="implied_ids" eval="[(4, ref('group_mat_mgmt_user'))]"/>
        <field name="users" eval="[(4, ref('base.user_root'))]"/>
    </record>

At the view part I have added like this

<menuitem name="Materials Management" id="menu_mat_mgmt_root"
        groups="group_mat_mgmt_manager,group_mat_mgmt_user"
        sequence="80"/>

then the permission given at the csv but i got an error like this

File "C:\OpenErp\openerp\openobject-server\openerp\addons\base\ir\ir_model.py", line 850, in _get_id raise ValueError('No such external ID currently defined in the system: %s.%s' % (module, xml_id)) alueError: No such external ID currently defined in the system: mat_mgmt.group_mat_mgmt_manager

1

1 Answers

3
votes

It looks like you did not add files in openerp.py in well sequence. Are you getting this error from CSV file or from View.xml file ?

You need to check openerp.py file. You may be assign first ir.model.access.csv/module_view.xml and after that, module_security.xml in 'data' attribute. So It will go first checking ir.model.access.csv/module_view.xml and it will not find that group, that you created in security.xml and that will be load after loading ir.model.access.csv/module_view.xml files. You can check it and you need to pass first security.xml and after that, ir.model.access.csv/module_view.xml files in openerp.py.

You can also check by assigning group like this : module_name.GROUP_XML_ID wherever you did assign/use those groups.