ParseError:“视图定义无效

时间:2017-02-11 22:49:54

标签: xml openerp odoo-9

我正在尝试在Odoo 9上安装Odoo 8模块。我收到了ParseError:“视图定义无效。我尝试阅读文档,但我只是在学习并发现难以理解

我收到错误

File "/opt/odoo/openerp/models.py", line 1281, in _validate_fields
    raise ValidationError('\n'.join(errors))
ParseError: "Invalid view definition

Error details:
Element '<xpath expr="//link[@id='pos-stylesheet']">' cannot be located in parent view

Error context:
View `select_cashier_module_index index`
[view_id: 699, xml_id: n/a, model: n/a, parent_id: 636]
None" while parsing None:7, near
<data name="select_cashier_module_index index" inherit_id="point_of_sale.index">
            <xpath expr="//link[@id='pos-stylesheet']" position="after">
                <link rel="stylesheet" href="/pos_select_cashier/static/src/css/pos.css"/>
            </xpath>

        </data>

这是templates.xml文件

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

<openerp>
    <data>

        <template id="index" name="select_cashier_module_index index"
                  inherit_id="point_of_sale.index">
            <xpath expr="//link[@id='pos-stylesheet']" position="after">
                <link rel="stylesheet" href="/pos_select_cashier/static/src/css/pos.css"/>
            </xpath>

        </template>

        <template id="assets_backend" name="select_cashier_module assets"
                  inherit_id="web.assets_backend">
            <xpath expr="//script[last()]" position="after">
                <script type="text/javascript" src="/pos_select_cashier/static/src/js/db.js"></script>
                <script type="text/javascript" src="/pos_select_cashier/static/src/js/models.js"></script>
                <script type="text/javascript" src="/pos_select_cashier/static/src/js/screens.js"></script>
                <script type="text/javascript" src="/pos_select_cashier/static/src/js/widgets.js"></script>
                <script type="text/javascript" src="/pos_select_cashier/static/src/js/main.js"></script>
            </xpath>
        </template>
    </data>
</openerp>

2 个答案:

答案 0 :(得分:0)

由于您将其标记为Odoo-9,因此我查看了Odoo 9代码以解决您的问题。

我相信您设置为继承的point_of_sale.indexhere,其<link>没有id = "pos-stylesheet"

然而,它位于POS资产模板here中,因此您需要做的是将代码更改为继承自point_of_sale.assets而不是point_of_sale.index

因此:

<template id="index" name="select_cashier_module_index index"
              inherit_id="point_of_sale.assets">
    <xpath expr="//link[@id='pos-stylesheet']" position="after">
        <link rel="stylesheet" href="/pos_select_cashier/static/src/css/pos.css"/>
    </xpath>

</template>

另外,请确保__openerp__.py已将point_of_sale列为您的某个依赖项。

答案 1 :(得分:0)

这是一个正确的代码: -

<template id="assets" inherit_id="point_of_sale.assets">
      <xpath expr="." position="inside">
          <script type="text/javascript" src="/pos_restaurant/static/lib/js/jquery.event.drag-2.2.js"></script>
          <script type="text/javascript" src="/pos_restaurant/static/src/js/multiprint.js"></script>
          <script type="text/javascript" src="/pos_restaurant/static/src/js/splitbill.js"></script>
          <script type="text/javascript" src="/pos_restaurant/static/src/js/printbill.js"></script>
          <script type="text/javascript" src="/pos_restaurant/static/src/js/floors.js"></script>
          <script type="text/javascript" src="/pos_restaurant/static/src/js/notes.js"></script>
      </xpath>
      <xpath expr="//link[@id='pos-stylesheet']" position="after">
          <link rel="stylesheet" href="/pos_restaurant/static/src/css/restaurant.css" />
      </xpath>
    </template>

所以在你的清单文件中尝试添加

 'depends': ['point_of_sale'],