为什么我的访问权限模块不起作用

时间:2018-10-25 03:24:27

标签: python-2.7 odoo postgresql-9.5

当我尝试向项目添加访问权限时遇到了一些麻烦。 这是我在清单 .py

中加载的数据
'data': [
    'security/ir.model.access.csv',
    'security/security.xml',
    'views/views.xml',
    'views/templates.xml',
    'views/partner.xml',        
],

然后是我的ir.model.access.csv代码

  id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
kursus_user,kursus.user,model_training_kursus,group_training_user,1,1,1,1
sesi_user,sesi.user,model_training_sesi,group_training_user,1,1,1,1
kursus_create,kursus.create,model_training_kursus,group_training_create,1,0,1,0
kursus_read,kursus.read,model_training_kursus,group_training_read,1,0,0,0
kursus_update,kursus.update,model_training_kursus,group_training_update,1,1,0,0
kursus_delete,kursus.delete,model_training_kursus,group_training_delete,1,0,0,1
sesi_create,sesi.create,model_training_sesi,group_training_create,1,0,1,0
sesi_read,sesi.read,model_training_sesi,group_training_read,1,0,0,0
sesi_update,sesi.update,model_training_sesi,group_training_update,1,1,0,0
sesi_delete,sesi.delete,model_training_sesi,group_training_delete,1,0,0,1

然后是我的security.xml文件

<odoo>
<record id='group_training_create' model='res.groups'>
    <field name='name'>Training / Akses Create</field>
</record>

<record id='group_training_read' model='res.groups'>
    <field name='name'>Training / Akses Read</field>
</record>

<record id='group_training_update' model='res.groups'>
    <field name='name'>Training / Akses Update</field>
</record>

<record id='group_training_delete' model='res.groups'>
    <field name='name'>Training / Akses Delete</field>
</record>


<record id='group_training_user' model='res.groups'>
    <field name='name'>Training / User</field>
</record>

<record id='group_training_manager' model='res.groups'>
    <field name='name'>Training / Manager</field>
    <field name='implied_ids' eval="[(4,ref('training_odoo.group_training_user'))]"/>
    <field name='users' eval='[(4, ref("base.user_root")'/>
</record>

运行代码时,我收到类似这样的错误消息

  

异常:模块加载training_odoo失败:无法处理文件training_odoo / security / ir.model.access.csv:    在字段“组”中找不到外部ID“ group_training_user”的匹配记录

有人可以帮助我找到解决方案吗?也许我那里有错字,但我不知道它在哪里

2 个答案:

答案 0 :(得分:0)

module_name之前添加group_name

EX:

 sesi_user,sesi.user,model_training_sesi,module_name.group_training_user,1,1,1,1

希望它会对您有所帮助。

答案 1 :(得分:0)

只需按此顺序编辑清单 .py文件

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