2017-02-11 72 views
0

我想在Odoo 9上安裝Odoo 8模塊。我得到ParseError:」無效的視圖定義。我試着閱讀文檔,但我只是在學習,發現很難遵循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> 

回答

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作爲一個依賴。

+0

改變point_of_sale.index到point_of_sale.assets我得到提高NOTFOUND(後)未找到404.我根本不能加載Odoo。我創建了另一個數據庫,並再次嘗試使用沒有其他模塊的銷售點,但我得到了同樣的錯誤。 – user2379186

+0

你可以發佈完整的追溯? 404錯誤是前端的錯誤,通常與錯誤的URL一樣簡單。 –

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'],