我现在在 openerp 中创建了一个新模块,我想为该模块提供安全性,因为我在模块文件夹中创建了一个名为“security”的文件夹,并在其中创建了一个 xml 文件和 ir.model.access.csv 文件我的目标是我想为我的模块创建两个角色,一个是经理,另一个是用户。 为此,我在 xml 文件中添加了以下代码
<record id="group_mat_mgmt_user" model="res.groups">
<field name="name">User</field>
<field name="category_id" ref="base.module_category_mat_mgmt"/>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
</record>
<record id="group_mat_mgmt_manager" model="res.groups">
<field name="name">Manager</field>
<field name="category_id" ref="base.module_category_mat_mgmt"/>
<field name="implied_ids" eval="[(4, ref('group_mat_mgmt_user'))]"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
在 View 部分我添加了这样的
<menuitem name="Materials Management" id="menu_mat_mgmt_root"
groups="group_mat_mgmt_manager,group_mat_mgmt_user"
sequence="80"/>
然后在 csv 中给予许可,但我收到这样的错误
File "C:\OpenErp\openerp\openobject-server\openerp\addons\base\ir\ir_model.py", line 850, in _get_id raise ValueError('No such external ID currently defined in the system: %s.%s' % (module, xml_id)) alueError: No such external ID currently defined in the system: mat_mgmt.group_mat_mgmt_manager
最佳答案
看来您没有按顺序在 openerp.py 中添加文件。您是否从 CSV 文件或 View.xml 文件中收到此错误?
您需要检查openerp.py 文件。您可以先分配 ir.model.access.csv/module_view.xml,然后在“data”属性中分配 module_security.xml。因此,它将首先检查 ir.model.access.csv/module_view.xml,并且不会找到您在 security.xml 中创建的组,该组将在加载 ir.model.access.csv/module_view.xml 后加载文件。你可以检查一下,你需要先传递 security.xml,然后传递 openerp.py 中的 ir.model.access.csv/module_view.xml 文件。
您还可以通过分配组进行检查,如下所示: module_name.GROUP_XML_ID 无论您在何处分配/使用这些组。
关于odoo - 在 openerp 中向模块添加安全性时发生错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16601836/