安装插件时出现 Odoo 错误:查看继承错误

Odoo Error when installing Addon : View Inheritance Error

目前我正在为 odoo13 的 timesheet_grid 模块开发一个插件。 我遇到了这个问题,找不到任何解决方案。我认为它说视图名称已被占用,对吗?

我的代码

<?xml version="1.0" encoding="utf-8"?>

<odoo>

    <record id="timesheet_view_grid_addon_by_project" model="ir.ui.view">
        <field name="name">timesheet.view.grid.by.project.addon</field>
        <field name="model">account.analytic.line</field>
        <field name="inherit_id" ref="timesheet_grid.timesheet_view_grid_by_project"/>
        <grid string="Timesheets" adjustment="object" adjust_name="adjust_grid">
          <xpath expr="//field[@name='project_id']" position="replace">
          <field name="project_id" type="row" section="1" color="blue !important"/>
          </xpath>
        </grid>
    </record>
</odoo>

错误信息:

Odoo Server Error
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 624, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 310, in _handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
  File "/usr/lib/python3/dist-packages/odoo/tools/pycompat.py", line 14, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 669, in dispatch
    result = self._call_function(**self.params)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 350, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/service/model.py", line 94, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 339, in checked_call
    result = self.endpoint(*a, **kw)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 915, in __call__
    return self.method(*args, **kw)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 515, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1331, in call_button
    action = self._call_kw(model, method, args, kwargs)
  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1319, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/usr/lib/python3/dist-packages/odoo/api.py", line 387, in call_kw
    result = _call_kw_multi(method, model, args, kwargs)
  File "/usr/lib/python3/dist-packages/odoo/api.py", line 374, in _call_kw_multi
    result = method(recs, *args, **kwargs)
  File "<decorator-gen-60>", line 2, in button_immediate_install
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 72, in check_and_log
    return method(self, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 463, in button_immediate_install
    return self._button_immediate_function(type(self).button_install)
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_module.py", line 573, in _button_immediate_function
    modules.registry.Registry.new(self._cr.dbname, update_module=True)
  File "/usr/lib/python3/dist-packages/odoo/modules/registry.py", line 86, in new
    odoo.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 421, in load_modules
    processed_modules += load_marked_modules(cr, graph,
  File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 313, in load_marked_modules
    loaded, processed = load_module_graph(
  File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 225, in load_module_graph
    load_data(cr, idref, mode, kind='data', package=package, report=report)
  File "/usr/lib/python3/dist-packages/odoo/modules/loading.py", line 68, in load_data
    tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind, report)
  File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 736, in convert_file
    convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
  File "/usr/lib/python3/dist-packages/odoo/tools/convert.py", line 786, in convert_xml_import
    relaxng.assert_(doc)
  File "src/lxml/etree.pyx", line 3631, in lxml.etree._Validator.assert_
**AssertionError: Element odoo has extra content: record, line 5**

正如我所说,我认为它与视图 ID 有关,不是吗?我尝试更改名称但没有成功。 谢谢,如果有任何帮助或建议,我将不胜感激。 for循环

您的 xml 缺少一个节点。

缺少节点:

<?xml version="1.0" encoding="utf-8"?>

<odoo>

    <record id="timesheet_view_grid_addon_by_project" model="ir.ui.view">
        <field name="name">timesheet.view.grid.by.project.addon</field>
        <field name="model">account.analytic.line</field>
        <field name="inherit_id" ref="timesheet_grid.timesheet_view_grid_by_project"/>
        <field name="arch" type="xml">
            <grid string="Timesheets" adjustment="object" adjust_name="adjust_grid">
              <xpath expr="//field[@name='project_id']" position="replace">
                  <field name="project_id" type="row" section="1" color="blue !important"/>
              </xpath>
            </grid>
        </field>
    </record>
</odoo>