为odoo中新创建的模型(模型)更新acl时模块加载失败
Posted
技术标签:
【中文标题】为odoo中新创建的模型(模型)更新acl时模块加载失败【英文标题】:Module loading failed while updating acl for newly created model(Model) in odoo 【发布时间】:2018-06-05 10:52:28 【问题描述】:下面我提到了 grievance.redressal(model)、视图和访问控制列表。我试图在 ir.model.access.csv 中为 grievance.redressal(model) 添加 acl。但是服务器更新时模块失败
类文件:
class grievance_redressal(models.Model):
_name = 'grievance.redressal'
name = fields.Char('Name with Initial', size=64)
查看:
<record id="view_grievance_redressal_form" model="ir.ui.view" >
<field name="name">grievance.redressal.form</field>
<field name="model">grievance.redressal</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Grievance Redressal" version="7.0">
<sheet>
<group>
<field name="name"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="view_grievance_redressal_tree" model="ir.ui.view">
<field name="name">grievance.redressal.tree</field>
<field name="model">grievance.redressal</field>
<field name="arch" type="xml">
<tree string="Grievance Redressal">
<field name="name"/>
</tree>
</field>
</record>
<record id="action_grievance_redressal" model="ir.actions.act_window">
<field name="name">Grievance Redressal</field>
<field name="res_model">grievance.redressal</field>
<field name="view_mode">tree,form</field>
<field name="view_type">form</field>
</record>
<menuitem action="action_grievance_redressal" id="grievance_redressal_menu" parent="operations" sequence="30"/>
ACL:
access_grievance_redressal_group_officer, access.grievance.redressal.group.officer, model_grievance.redressal, group_officer 1,0,0,0
如果我尝试在 odoo 中为新创建的模型(grievance.redressal)添加 ACL。但会引发以下错误
File "/home/user/Projects/test/test-server/openerp/service/server.py", line 885, in preload_registries
registry = RegistryManager.new(dbname, update_module=update_module)
File "/home/user/Projects/test/test-server/openerp/modules/registry.py", line 385, in new
openerp.modules.load_modules(registry._db, force_demo, status, update_module)
File "/home/user/Projects/test/test-server/openerp/modules/loading.py", line 333, in load_modules
force, status, report, loaded_modules, update_module)
File "/home/user/Projects/test/test-server/openerp/modules/loading.py", line 237, in load_marked_modules
loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
File "/home/user/Projects/test/test-server/openerp/modules/loading.py", line 156, in load_module_graph
_load_data(cr, module_name, idref, mode, kind='data')
File "/home/user/Projects/test/test-server/openerp/modules/loading.py", line 98, in _load_data
tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
File "/home/user/Projects/test/test-server/openerp/tools/convert.py", line 846, in convert_file
convert_csv_import(cr, module, pathname, fp.read(), idref, mode, noupdate)
File "/home/user/Projects/test/test-server/openerp/tools/convert.py", line 914, in convert_csv_import
raise Exception(_('Module loading %s failed: file %s could not be processed:\n %s') % (module, fname, warning_msg))
Exception: Module loading test failed: file test/security/ir.model.access.csv could not be processed:
Line 1 : model+AF8-id
csv 文件:
【问题讨论】:
你能把test/security/ir.model.access.csv的全部内容贴出来吗?我错过了第一行,为什么到处都是空格? 请找到下面提到的 CSV 文件 ID名称MODEL_ID:ID GROUP_ID:ID perm_read perm_write perm_create perm_unlink access_grievance_redressal_vvcoe_group_student access.grievance.redressal.vvcoe.group.student model_grievance_redressal vvcoe_group_student 1 0 0 0 access_grievance_redressal_vvcoe_group_library_management access.grievance.redressal.vvcoe.group.library .management model_grievance_redressal vvcoe_group_library_management 1 0 0 0 我假设问题出在 model_id:id 中的数据上。数据应采用“module_name.model_model_name”格式。例如,如果您的模块名称是“grievance”,模型是“grievance.redressal”,那么数据应该类似于“grivance.model_grievance_redressal”。 谢谢。我也试过了。问题出在编辑工具上 【参考方案1】:似乎是 OpenOffice 和 csv 文件的编码问题。您应该将文件保存为 UTF-8。更多信息请查看here。
【讨论】:
是的。编辑工具(libreoffice)出现问题【参考方案2】:我已经解决了这个问题。问题是在 libreoffice 中编辑 CSV 有一段时间失败了。当我在文本编辑器中编辑 CSV 文件时工作正常。谢谢
我在 csv 中添加了 ACL,使用文本编辑器作为编辑工具:
access_grievance_redressal_group_student,access.grievance.redressal.group.student,model_grievance_redressal,group_student,1,0,0,0
【讨论】:
以上是关于为odoo中新创建的模型(模型)更新acl时模块加载失败的主要内容,如果未能解决你的问题,请参考以下文章