我的xml视图文件中有以下代码,它继承自另一个视图:
<xpath expr="//notebook/page[@string='Accounting']/group" position="replace"></xpath>
但它给了我错误:
元素"'<xpath expr="//notebook/page[@string='Accounting']/group">'"
无法在父视图中找到
虽然“会计”标签位于父视图中。我做错了什么?谢谢你的帮助。
以下是我继承的观点:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="product_template_form_view" model="ir.ui.view">
<field name="name">product.template.form.inherit</field>
<field name="model">product.template</field>
<field name="priority">5</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<page string="Sales" position="after">
<page string="Accounting" groups="account.group_account_invoice">
<group>
<label for="categ_id" string="Internal Category"/>
<div><field name="categ_id" colspan="3" nolabel="1"/></div>
</group>
<group name="properties">
<group>
<field name="property_account_income" domain="[('type','=','other')]" groups="account.group_account_user"/>
<field name="taxes_id" colspan="2" widget="many2many_tags"/>
</group>
<group>
<field name="property_account_expense" domain="[('type','=','other')]" groups="account.group_account_user"/>
<field name="supplier_taxes_id" colspan="2" widget="many2many_tags"/>
</group>
</group>
</page>
</page>
</field>
</record>
<record id="product_template_search_view" model="ir.ui.view">
<field name="name">product.template.search</field>
<field name="model">product.template</field>
<field name="mode">primary</field>
<field name="inherit_id" ref="product.product_template_search_view"/>
<field name="arch" type="xml">
<field name="product_variant_ids" position="after">
<field name="categ_id"/>
</field>
<xpath expr="//group[@string='Group by...']" position="inside">
<filter string='Category' icon="terp-stock_symbol-selection" domain="[]" context="{'group_by' : 'categ_id'}"/>
</xpath>
</field>
</record>
<record id="view_category_property_form" model="ir.ui.view">
<field name="name">product.category.property.form.inherit</field>
<field name="model">product.category</field>
<field name="inherit_id" ref="product.product_category_form_view"/>
<field name="arch" type="xml">
<data>
<xpath expr="//group[@name='parent']" position="inside">
<group name="account_property" string="Account Properties" colspan="2">
<field name="property_account_income_categ" domain="[('type','<>','view'),('type','<>','consolidation')]"/>
<field name="property_account_expense_categ" domain="[('type','<>','view'),('type','<>','consolidation')]"/>
</group>
</xpath>
</data>
</field>
</record>
</data>
</openerp>
这是继承前一个视图并给我错误的视图:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="product_config_form_view" model="ir.ui.view">
<field name="name">product.config.form.view</field>
<field name="model">product.template</field>
<field name="type">form</field>
<field name="inherit_id" ref="product.product_template_only_form_view" />
<field name="arch" type="xml">
<label for="name" position="replace">
<label for="name" invisible="1"/>
</label>
<field name="name" position="replace">
<div style="font-size:10pt;">
<label for="class_id" string="Item Class" />
</div>
<div style="font-size:10pt;">
<field name="class_id" colspan="3" nolabel="1" on_change="onchange_class_id(class_id)"
/> </div>
<div style="font-size:10pt;">
<label for="name" string="Item Description"/>
</div>
<div style="font-size:10pt;" >
<field name="name" colspan="3" nolabel="1"/>
</div>
</field>
<field name="default_code" position="replace" >
<field name="default_code" string="Item Number" />
</field>
<xpath expr="//notebook/page[@string='Accounting']/group" position="replace">
</xpath>
</field>
</record>
<record id="product_config_tree_view" model="ir.ui.view">
<field name="name">product.config.tree.view</field>
<field name="model">product.class</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Product">
<field name="default_code" string="Class ID" colspan="3" nolabel="1" />
<field name="name" string="Class Description" colspan="3" nolabel="1"/>
</tree>
</field>
</record>
<record id="class_search_view" model="ir.ui.view">
<field name="name">class.search.view</field>
<field name="model">product.class</field>
<field name="arch" type="xml">
<search string="Class">
<field name="name" string="Class Description" filter_domain="['|',('default_code','ilike',self),
('name','ilike',self)]" />
</search>
</field>
</record>
</data>
</openerp>
答案 0 :(得分:2)
使用//notebook
启动xpath表达式。
因此,您的xpath选择所有notebook
元素,无论它们在文档中的位置如何。
但我没有看到任何包含笔记本的xml标签。
这个表达式:
<xpath expr="//page[@string='Accounting']/group" position="replace"></xpath>
选择以下所有组元素:
<page string="Accounting" groups="account.group_account_invoice">