gpt4 book ai didi

python - XMLSyntaxError :Input is not proper UTF-8, 表示编码,Odoo

转载 作者:太空宇宙 更新时间:2023-11-03 17:12:38 25 4
gpt4 key购买 nike

我正在 odoo local(离线)上创建一个模块。要创建它,它需要模型(Python 中)和 View (Xml 中)。然后将安装该模块,但创建 View 后出现错误。

这是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>`

在创建 View 时,将其放入 <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`

最佳答案

我重新格式化了你的 xml 以更好地检查它,我注意到两件事:1. data 标签丢失2. xml 的开头和结尾有两个“'”字符。因为您的跟踪显示“输入不是正确的 UTF-8”,所以我想到问题可能是由这个完全相同的字符引起的。

检查您的源文件是否也存在并删除它们,然后添加如下数据标签。

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

关于python - XMLSyntaxError :Input is not proper UTF-8, 表示编码,Odoo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33941862/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com