我是使用 Odoo 和 Python 进行开发的新手,我正在尝试创建一个使用数据库表并在视图中显示表的模块,这就是我所拥有的:
# models.py
from odoo import models, fields
class pc_clientess(models.Model):
_name = "clientes.pc_clientes"
_description = "Tabla de clientes"
_table = "pc_clientes"
xempgen_id = fields.Char(string="Empresa ID", required=True)
xcliente_id = fields.Char(string="Cliente ID", required=True)
并且:
<odoo>
<data>
<record id="clientes_tree_view" model="ir.ui.view">
<field name="name">clientes.tree.view</field>
<field name="model">clientes.pc_clientess</field>
<field name="arch" type="xml">
<tree>
<field name="xempgen_id"/>
<field name="xcliente_id"/>
</tree>
</field>
</record>
<record id="clientes_form_view" model="ir.ui.view">
<field name="name">clientes.form.view</field>
<field name="model">clientes.pc_clientess</field>
<field name="arch" type="xml">
<form>
<field name="xempgen_id"/>
<field name="xcliente_id"/>
</form>
</field>
</record>
<record id="clientes_action" model="ir.actions.act_window">
<field name="name">Clientes</field>
<field name="res_model">clientes.pc_clientess</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem id="menu_root" name="Rioma"/>
<menuitem id="menu_clientes" name="Clientes" parent="menu_root"/>
<menuitem id="menu_clientes_list" name="Clientes List"
parent="menu_clientes" action="clientes_action"/>
</data>
</odoo>
但是当我在 Odoo 上激活我的模块时,它给我带来了这个错误:
RPC_ERROR
Odoo Server Error
Occured on localhost:8069 on model ir.module.module and id 16 on 2024-11-19 08:40:10 GMT
Traceback (most recent call last):
File "C:\odoo\odoo\tools\convert.py", line 537, in _tag_root
f(rec)
File "C:\odoo\odoo\tools\convert.py", line 437, in _tag_record
record = model._load_records([data], self.mode == 'update')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\odoo\odoo\models.py", line 5446, in _load_records
records = self._load_records_create([data['values'] for data in to_create])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\odoo\odoo\models.py", line 5350, in _load_records_create
records = self.create(vals_list)
^^^^^^^^^^^^^^^^^^^^^^
File "<decorator-gen-138>", line 2, in create
File "C:\odoo\odoo\api.py", line 480, in _model_create_multi
return create(self, arg)
^^^^^^^^^^^^^^^^^
File "c:\odoo\addons\website\models\ir_ui_view.py", line 64, in create
return super().create(vals_list)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "<decorator-gen-9>", line 2, in create
File "C:\odoo\odoo\api.py", line 480, in _model_create_multi
return create(self, arg)
^^^^^^^^^^^^^^^^^
File "C:\odoo\odoo\addons\base\models\ir_ui_view.py", line 516, in create
result = super(View, self.with_context(ir_ui_view_partial_validation=True)).create(vals_list)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<decorator-gen-0>", line 2, in create
File "C:\odoo\odoo\api.py", line 480, in _model_create_multi
return create(self, arg)
^^^^^^^^^^^^^^^^^
File "C:\odoo\odoo\models.py", line 4954, in create
records = self._create(data_list)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\odoo\odoo\models.py", line 5121, in _create
row.append(field.convert_to_column_insert(stored[fname], self, stored))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\odoo\odoo\fields.py", line 982, in convert_to_column_insert
value = self.convert_to_column(value, record, values, validate)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\odoo\odoo\fields.py", line 2925, in convert_to_column
value = self.convert_to_cache(value, record)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\odoo\odoo\fields.py", line 2935, in convert_to_cache
raise ValueError("Wrong value for %s: %r" % (self, value))
ValueError: Wrong value for ir.ui.view.type: 'tree'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\odoo\odoo\http.py", line 1954, in _transactioning
return service_model.retrying(func, env=self.env)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\odoo\odoo\service\model.py", line 137, in retrying
result = func()
^^^^^^
File "C:\odoo\odoo\http.py", line 1921, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\odoo\odoo\http.py", line 2168, in dispatch
result = self.request.registry['ir.http']._dispatch(endpoint)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\odoo\odoo\addons\base\models\ir_http.py", line 329, in _dispatch
result = endpoint(**request.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\odoo\odoo\http.py", line 727, in route_wrapper
result = endpoint(self, *args, **params_ok)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\odoo\addons\web\controllers\dataset.py", line 40, in call_button
action = call_kw(request.env[model], method, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\odoo\odoo\api.py", line 517, in call_kw
result = getattr(recs, name)(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\odoo\venv\Lib\site-packages\decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\odoo\odoo\addons\base\models\ir_module.py", line 75, in check_and_log
return method(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\odoo\odoo\addons\base\models\ir_module.py", line 477, in button_immediate_install
return self._button_immediate_function(self.env.registry[self._name].button_install)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\odoo\odoo\addons\base\models\ir_module.py", line 601, in _button_immediate_function
registry = modules.registry.Registry.new(self._cr.dbname, update_module=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\odoo\venv\Lib\site-packages\decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\odoo\odoo\tools\func.py", line 97, in locked
return func(inst, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\odoo\odoo\modules\registry.py", line 131, in new
odoo.modules.load_modules(registry, force_demo, status, update_module)
File "C:\odoo\odoo\modules\loading.py", line 479, in load_modules
processed_modules += load_marked_modules(env, graph,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\odoo\odoo\modules\loading.py", line 363, in load_marked_modules
loaded, processed = load_module_graph(
^^^^^^^^^^^^^^^^^^
File "C:\odoo\odoo\modules\loading.py", line 226, in load_module_graph
load_data(env, idref, mode, kind='data', package=package)
File "C:\odoo\odoo\modules\loading.py", line 70, in load_data
tools.convert_file(env, package.name, filename, idref, mode, noupdate, kind)
File "C:\odoo\odoo\tools\convert.py", line 608, in convert_file
convert_xml_import(env, module, fp, idref, mode, noupdate)
File "C:\odoo\odoo\tools\convert.py", line 679, in convert_xml_import
obj.parse(doc.getroot())
File "C:\odoo\odoo\tools\convert.py", line 594, in parse
self._tag_root(de)
File "C:\odoo\odoo\tools\convert.py", line 537, in _tag_root
f(rec)
File "C:\odoo\odoo\tools\convert.py", line 550, in _tag_root
raise ParseError('while parsing %s:%s, somewhere inside\n%s' % (
odoo.tools.convert.ParseError: while parsing file:/c:/odoo/modules/clientes/views/templates.xml:4, somewhere inside
<record id="clientes_tree_view" model="ir.ui.view">
<field name="name">clientes.tree.view</field>
<field name="model">clientes.pc_clientess</field>
<field name="arch" type="xml">
<tree>
<field name="xempgen_id"/>
<field name="xcliente_id"/>
</tree>
</field>
</record>
The above server error caused the following client error:
RPC_ERROR: Odoo Server Error
RPC_ERROR
at makeErrorFromResponse (http://localhost:8069/web/assets/c24f766/web.assets_web.min.js:3061:163)
at XMLHttpRequest.<anonymous> (http://localhost:8069/web/assets/c24f766/web.assets_web.min.js:3066:13)
我不知道该怎么办,几个月前我按照指南进行了尝试,它确实有效,但现在它给了我这个我无法解决的错误,提前感谢大家。
错误说:
ValueError: Wrong value for ir.ui.view.type: 'tree'
您应该检查您的 odoo 版本中允许哪种类型的视图