2017-03-21 43 views
2

我需要使用xpath在<form>内添加标签<sheet>。我试过了下面的代码:使用xpath odoo 8在表单标签内添加表单标签

<xpath expr="//form[@string='Bank account']" position="inside"> 
    <sheet></sheet> 
</xpath> 

添加了工作表,但在表单标签之后。

enter image description here

我该怎么办呢?

+0

我认为字符串在xpath中无效,请尝试使用表单name.expr =“// form [@ name ='name of your form']” –

+0

该表单标签没有名称。 – KbiR

+0

然后,您需要从xpath中的表单提供特定字段的名称,并在之前或之后给出您需要的位置。 –

回答

0

请尽量

<xpath expr="//form" position="inside"> 
    <sheet></sheet> 
</xpath> 

<xpath expr="//form/group[1]" position="before"> 
    <sheet></sheet> 
</xpath> 

,如果你给了内部形状任何一组标签

+0

谢谢缅甸..但它不工作。 – KbiR

+0

然后提供实际的代码,我根据你的问题中的代码回答 –

0

当您使用position="inside"发生的事情是,你插入的片被追加为表单中的最后一项。你不需要这样的东西,你需要的是//form[@string='Bank account']这个表格包含一个表格和该表格以包含表格的所有子元素。

看看下面工作的XPath为您提供:

<xpath expr="//form[@string='Bank account']" position="inside"> 
    <sheet> 
    <xpath expr="//form[@string='Bank account']/[not(name()='sheet')]"/> 
    <xpath expr="//form[@string='Bank account']/[not(name()='sheet')]" position="replace"/> 
    </sheet> 
</xpath> 

我在这里做的是:

1)添加纸张形式

2)中选择的所有项目(除了我刚刚添加的纸张并将它们放在纸张内部)

3)为了避免在纸张和外部都有物品,我将外部取下。

+0

你能解释一下这个'/ [not(name()='sheet')'。这些字段不在表单内。 – KbiR