AccessError when users edit many2one field in custom module

540 Views Asked by At

I created a custom module to add some fields into Partner data. Everything seems to work well but no admin users can't edit many2one fields. It shows the following message (as if any permissions configurations were wrong with that model):

enter image description here

After doing what you asked, this is what happens:

This is the error I get:

Exception: Fall\xf3 el m\xf3dulo cargando cant_neg_dir: no se pudo procesar el archivo cant_neg_dir/security/ir.model.access.csv: Line 1 : No se han encontrado registros coincidentes para id. externo 'group_name_test_user' en el campo 'Object'

And this is what I have in my files:

ir.model.access.csv

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sector_user,sector.user,group_name_test_user,base.group_user,1,1,1,1

cant_dir_security.xml

<?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>

cant_neg_dir.py

import openerp
from openerp.osv import fields, osv, orm
from openerp import models


class poligono(models.Model):
    _name = "poligono"
    _rec_name= "poligono_name"
    _columns = {
        'poligono_name': fields.char('Polígono', required=True),   
}  

class sector(models.Model):
    _name = "sector"
    _rec_name= "sector_name"
    _columns = {
        'sector_name': fields.char('Sector', required=True),   
}   

class municipio(models.Model):
    _name = "municipio"
    _rec_name= "municipio_name"
    _columns = {
        'municipio_name': fields.char('Municipio', required=True),   
}

Again, thanks for your help.

Regards.

1

There are 1 best solutions below

9
On

You need to give security access right to new object.

We can do it via code. For example:

access_sector,sector.user,model_sector,base.group_user,1,1,1,1

For more details security/ir.model.access.csv and Odoo Security Documentation.

EDIT

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sector,sector.user,model_sector,base.group_user,1,1,1,1

EDIT

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_sector_user,sector.user,your_module_name.group_name_test_user,base.group_user,1,1,1,1

And make sure openerp.py file will be look like following position file name

cant_dir_security.xml
ir.model.access.csv