This question has been flagged
1 Reply
19605 Views

I'm learning OpenERP development and I'm stuck in a problem related to security and menu access rights, I've developed a very basic module which has just one test class and one test menu with a submenu and tree,form views .

The problem is when I log in using any user other than admin I can't access this module (I can't see the Test menu), although it's accessible to the admin user (and only to him)

Note that I didn't add any access rights or access rules (AFAIK from the documentation it should be global and accessible to all users !! )

Here is my module :

__init__.py

import testmod

.

__openerp__.py

{
'name': "Test Module",
'description': "Basic example of a (future) web module",
'category': 'Hidden',
'depends': ['base'],
'data': [
    'test_view.xml',
],
'installable': True,
'application': False,
'auto_install': False,
}

.

testmod.py

from openerp.osv import fields, osv

class testmod_test(osv.Model):

    _name = 'testmod.test'
    _description = 'Test Model'
    _columns = {
    'test1': fields.char('Test 1', size=32, required=True, help='Test 1 help'),
    'test2': fields.float('Test 2', help='Test 2 help'),
    }

testmod_test()

.

test_view.xml

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

<record id="testmod_test_form" model="ir.ui.view">
    <field name="name">testmod.test.form</field>
    <field name="model">testmod.test</field>
    <field name="arch" type="xml">
      <form string="Test" version="7.0">  
        <field name="test1" />
        <field name="test2"/>

      </form>
    </field>
</record>

<record id="testmod_test_tree" model="ir.ui.view">
  <field name="name">testmod.test.tree</field>
  <field name="model">testmod.test</field>
  <field name="arch" type="xml">
    <tree string="Test">
      <field name="test1" />
       <field name="test2"/>
    </tree>
  </field>
</record>



<record model="ir.actions.act_window" id="action_testmod_test">
  <field name="name">Test</field>
  <field name="res_model">testmod.test</field>
  <field name="view_type">form</field>
  <field name="view_mode">tree,form</field>

</record>


<menuitem 
          name="Test" 
          id="menu_testmod_test" 

          />

<menuitem 
          name="Test sub" 
          parent="menu_testmod_test"
          id="menu_testmod_test_sub" 

          />          
<menuitem
        name="Sub Test"
        id="menu_subtest"
        parent="menu_testmod_test_sub"
        action="action_testmod_test"    
        />


</data>
</openerp>

and I'm using OpenERP 7.0 in a linux platform (ubuntu 13.04)

Any help will be appreciated :), Thanks in advance

Avatar
Discard
Best Answer

the default access rights restrict to ONLY the admin, that is how good security works.

You must add access rights, it is better to create groups with access rights then add users to those groups but if you want a fast and direct globally available module here you go:

ir.model.access.csv

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

Make sure to import the the access file in your __openerp__.py file.

'data': [
   # your other files
    'security/ir.model.access.csv',
],
Avatar
Discard
Author

Thanks a million patently, you've saved me :) Seems that i've interpreted this sentence the wrong way "A menu that is not granted to any group is accessible to every user." Thanks again :)