Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Is the security "section" required in a new module ?

By
Anabela Damas
on 5/17/13, 12:49 PM 3,930 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.

1

Daniel Reis

--Daniel Reis--
3436
| 6 7 9
Lisbon, Portugal
--Daniel Reis--

Author of the "Odoo Development Essentials" book.

Applications Manager at Securitas Portugal

Github: https://github.com/dreispt

Twitter; @reis_pt


Daniel Reis
On 5/17/13, 3:00 PM

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.

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 =)

Versão Integral, Anabela Damas
on 5/20/13, 7:21 AM

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

Daniel Reis
on 5/23/13, 5:33 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 5/17/13, 12:49 PM
Seen: 3930 times
Last updated: 3/16/15, 8:10 AM