This question has been flagged
1 Reply
14421 Views

Hi,

I've created a new module and everything was working fine when I were just working with the admin user.

Now I've created a new user with all the rights and access that the user admin, but when I log in with this user my new module isn't visible. And my module is connected to Sales Quotation and when I try to access one quotation I get this error:

 WARNING testes17May openerp.addons.base.ir.ir_model: Access Denied by ACLs for operation: read, uid: 5, model: calculator.price
2013-05-17 14:18:50,479 4509 ERROR testes17May openerp.netsvc: Access Denied
Sorry, you are not allowed to access this document. Please contact your system administrator if you think this is an error.
(Document model: calculator.price)
Traceback (most recent call last):
  File "/opt/openerp-7.0/openerp/netsvc.py", line 289, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/opt/openerp-7.0/openerp/service/web_services.py", line 614, in dispatch
    res = fn(db, uid, *params)
  File "/opt/openerp-7.0/openerp/osv/osv.py", line 169, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/opt/openerp-7.0/openerp/osv/osv.py", line 125, in wrapper
    raise except_osv(inst.name, inst.value)
except_osv: (u'Access Denied', u'Sorry, you are not allowed to access this document. Please contact your system administrator if you think this is an error.\n\n(Document model: calculator.price)')

How do I fix this?

Is with the folder mymodule/security and the two files inside of it or is another way to do it?

Thanks

I've made the security folder with: mymodule/security/calc_security.xml:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data noupdate="0">
        <record model="res.groups" id="group_calc_user">
            <field name="name">User</field>
            <field name="comment">To show calculation sheet.</field>
            <field name="category_id" ref="module_category_group_calc_user"/>
        </record>
        <record model="ir.module.category" id="module_category_group_calc_user">
            <field name="name">User</field>
            <field name="description">Something...</field>
            <field name="sequence">20</field>
        </record>
    </data>
</openerp>

mymodule/__openerp__.py:

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
acess_infinitechoices_calc,calculator.price,model_calculator_price,group_calc_user,1,1,1,1

mymodule/security/ir.model.access.csv:

...
    'data_xml' : ['security/calc_security.xml','security/ir.model.access.csv'],
...

With my new user I still can't see my new module. What am I doing wrong? In this file the records were in a bad order: mymodule/security/calc_security.xml:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data noupdate="0">
        <record model="ir.module.category" id="module_category_group_calc_user">
            <field name="name">User</field>
            <field name="description">Something...</field>
            <field name="sequence">20</field>
        </record>
        <record model="res.groups" id="group_calc_user">
            <field name="name">User</field>
            <field name="comment">To show calculation sheet.</field>
            <field name="category_id" ref="module_category_group_calc_user"/>
        </record>
    </data>
</openerp>

Now is OK! Thanks for your help Daniel Reis.

Avatar
Discard
Best Answer

The admin builtin user is special, because it bypasses the ACL security checks. That's why you get security errors when you try with a new user that has exactly the same security groups as admin.

The solution is to add to your project a csv file to add permissions to groups on your new models. You can look into any official module to find an example.

Avatar
Discard
Author

Hi, I've updated my question with the code that I try to do by looking at the other modules, but I still can't see my new module with other users... do you know what am I doing wrong? Obrigada =)

To troubleshoot, you could use a standard res.group or try to define the permissions manually, through the Settings menus.