我正在odoo本地(离线)创建一个模块。要创建它,它需要Model(在python中)和View(在Xml中)。然后将安装该模块,但在创建视图后发生错误。
这是view.xml
<openerp>
<data>
<record id="view_form_todo_task_inherited" model="ir.ui.view">
<field name="name">Todo Task form – User extension</field>
<field name="model">todo.task</field>
<field name="inherit_id" ref="todo_app.view_form_todo_task"/>
<field name="arch" type="xml">
<field name="name" position="after">
<field name="user_id" />
</field>
<field name="is_done" position="before">
<field name="date_deadline" />
</field>
<field name="name" position="attributes">
<attribute name="string">I have to...<attribute/>
</field>
</field>
</record>
</data>
</openerp>`
在创建视图时,必须在<data>
内<openerp>
内进行,否则无法正常工作。
尝试安装模块时(也会编译代码),发生错误,表明view.xml文件有问题。 它说
XMLSyntaxError: Input is not proper UTF-8, indicate encoding !
Bytes: 0x96 0x20 0x55 0x73, line 4, column 28
这里是追溯
` Odoo Server Error
Traceback (most recent call last):
File "D:\Bitnami\odoo-8.0-12\apps\odoo\Lib\site-packages\odoo-8.0_20150423-py2.7.egg\openerp\http.py", line 530, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "D:\Bitnami\odoo-8.0-12\apps\odoo\Lib\site-packages\odoo-8.0_20150423-py2.7.egg\openerp\http.py", line 567, in dispatch
result = self._call_function(**self.params)
File "D:\Bitnami\odoo-8.0-12\apps\odoo\Lib\site-packages\odoo-8.0_20150423-py2.7.egg\openerp\http.py", line 303, in _call_function
return checked_call(self.db, *args, **kwargs)
File "D:\Bitnami\odoo-8.0-12\apps\odoo\Lib\site-packages\odoo-8.0_20150423-py2.7.egg\openerp\service\model.py", line 113, in wrapper
return f(dbname, *args, **kwargs)
File "D:\Bitnami\odoo-8.0-12\apps\odoo\Lib\site-packages\odoo-8.0_20150423-py2.7.egg\openerp\http.py", line 300, in checked_call
return self.endpoint(*a, **kw)
File "D:\Bitnami\odoo-8.0-12\apps\odoo\Lib\site-packages\odoo-8.0_20150423-py2.7.egg\openerp\http.py", line 796, in __call__
return self.method(*args, **kw)
File "D:\Bitnami\odoo-8.0-12\apps\odoo\Lib\site-packages\odoo-8.0_20150423-py2.7.egg\openerp\http.py", line 396, in response_wrap
response = f(*args, **kw)
File "D:\Bitnami\odoo-8.0-12\apps\odoo\Lib\site-packages\odoo-8.0_20150423-py2.7.egg\openerp\addons\web\controllers\main.py", line 940, in call_button
action = self._call_kw(model, method, args, {})
File "D:\Bitnami\odoo-8.0-12\apps\odoo\Lib\site-packages\odoo-8.0_20150423-py2.7.egg\openerp\addons\web\controllers\main.py", line 928, in _call_kw
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
File "D:\Bitnami\odoo-8.0-12\apps\odoo\Lib\site-packages\odoo-8.0_20150423-py2.7.egg\openerp\api.py", line 241, in wrapper
return old_api(self, *args, **kwargs)
File "D:\Bitnami\odoo-8.0-12\apps\odoo\Lib\site-packages\odoo-8.0_20150423-py2.7.egg\openerp\addons\base\module\module.py", line 450, in button_immediate_install
return self._button_immediate_function(cr, uid, ids, self.button_install, context=context)
File "D:\Bitnami\odoo-8.0-12\apps\odoo\Lib\site-packages\odoo-8.0_20150423-py2.7.egg\openerp\api.py", line 241, in wrapper
return old_api(self, *args, **kwargs)
File "D:\Bitnami\odoo-8.0-12\apps\odoo\Lib\site-packages\odoo-8.0_20150423-py2.7.egg\openerp\addons\base\module\module.py", line 498, in _button_immediate_function
registry = openerp.modules.registry.RegistryManager.new(cr.dbname, update_module=True)
File "D:\Bitnami\odoo-8.0-12\apps\odoo\Lib\site-packages\odoo-8.0_20150423-py2.7.egg\openerp\modules\registry.py", line 368, in new
openerp.modules.load_modules(registry._db, force_demo, status, update_module)
File "D:\Bitnami\odoo-8.0-12\apps\odoo\Lib\site-packages\odoo-8.0_20150423-py2.7.egg\openerp\modules\loading.py", line 355, in load_modules
loaded_modules, update_module)
File "D:\Bitnami\odoo-8.0-12\apps\odoo\Lib\site-packages\odoo-8.0_20150423-py2.7.egg\openerp\modules\loading.py", line 255, in load_marked_modules
loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
File "D:\Bitnami\odoo-8.0-12\apps\odoo\Lib\site-packages\odoo-8.0_20150423-py2.7.egg\openerp\modules\loading.py", line 176, in load_module_graph
_load_data(cr, module_name, idref, mode, kind='data')
File "D:\Bitnami\odoo-8.0-12\apps\odoo\Lib\site-packages\odoo-8.0_20150423-py2.7.egg\openerp\modules\loading.py", line 118, in _load_data
tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
File "D:\Bitnami\odoo-8.0-12\apps\odoo\Lib\site-packages\odoo-8.0_20150423-py2.7.egg\openerp\tools\convert.py", line 901, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
File "D:\Bitnami\odoo-8.0-12\apps\odoo\Lib\site-packages\odoo-8.0_20150423-py2.7.egg\openerp\tools\convert.py", line 974, in convert_xml_import
doc = etree.parse(xmlfile)
File "lxml.etree.pyx", line 3299, in lxml.etree.parse (src\lxml\lxml.etree.c:72421)
File "parser.pxi", line 1812, in lxml.etree._parseDocument (src\lxml\lxml.etree.c:106108)
File "parser.pxi", line 1832, in lxml.etree._parseFilelikeDocument (src\lxml\lxml.etree.c:106368)
File "parser.pxi", line 1727, in lxml.etree._parseDocFromFilelike (src\lxml\lxml.etree.c:105258)
File "parser.pxi", line 1146, in lxml.etree._BaseParser._parseDocFromFilelike (src\lxml\lxml.etree.c:100385)
File "parser.pxi", line 580, in lxml.etree._ParserContext._handleParseResultDoc (src\lxml\lxml.etree.c:94254)
File "parser.pxi", line 690, in lxml.etree._handleParseResult (src\lxml\lxml.etree.c:95690)
File "parser.pxi", line 620, in lxml.etree._raiseParseError (src\lxml\lxml.etree.c:94757)
XMLSyntaxError: Input is not proper UTF-8, indicate encoding !
Bytes: 0x96 0x20 0x55 0x73, line 4, column 28`
答案 0 :(得分:1)
我重新格式化了你的xml以便更好地检查它,我发现了两件事: 1.缺少数据标记 2.那里有两个&#34;&#39;&#34; xml开头和结尾的字符。因为你的踪迹说&#34;输入不正确UTF-8&#34;在我看来,问题可以由这个相同的角色给出。
检查您的源文件是否存在并删除它们,然后添加数据标记,如下所示。
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_form_todo_task_inherited" model="ir.ui.view">
<field name="name">Todo Task form – User extension</field>
<field name="model">todo.task</field>
<field name="inherit_id" ref="todo_app.view_form_todo_task"/>
<field name="arch" type="xml">
<data>
<field name="name" position="after">
<field name="user_id" />
</field>
<field name="is_done" position="before">
<field name="date_deadline" />
</field>
<field name="name" position="attributes">
<attribute name="string">I have to...</attribute>
</field>
</data>
</field>
</record>
</data>
</openerp>