Odoo 10 中的 Xpath contains()
Xpath contains() in Odoo 10
在 Odoo 10 中,我试图用 xpath 表达式替换此模板的内容。我想要做的只是 select 第一个 "Weight" 并将其替换为 "test"
<odoo>
<template id="report_delivery_document2" inherit_id="stock.report_delivery_document">
<xpath expr="//th[@name='td_sched_date_h']" position="after">
<th t-if="o.picking_type_id.code == 'outgoing' and o.carrier_id"><strong>Carrier</strong></th>
<th t-if="o.weight"><strong>Weight</strong></th>
</xpath>
<xpath expr="//td[@name='td_sched_date']" position="after">
<td t-if="o.picking_type_id.code == 'outgoing' and o.carrier_id">
<span t-field="o.carrier_id"/>
</td>
<td t-if="o.weight">
<span t-field="o.weight"/>
<span t-field="o.weight_uom_id"/>
</td>
</xpath>
</template>
在我的模块中,我正在尝试这段代码:
<odoo>
<template id="report_delivery_document3" inherit_id="stock_delivery_slip.report_sale_delivery_slip_createch">
<!-- <xpath expr="//th[contains(., 'Weight')]" position="replace"> -->
<!-- <xpath expr="//th/strong[text()='Weight']" position="replace"> -->
<th>test</th>
<!-- </xpath> -->
</template>
但是没有任何效果,我怎么能 select "Weight" 而不在 "report_delivery_document2" 中添加属性?
提前致谢。
您只需编辑该视图 (report_delivery_document2) 的翻译,然后更改:
<strong>Weight</strong>
进入:
<strong>test</strong>
但是如果你想保留 xpath,只需这样做:
<xpath expr="//th[@t-if='o.weight']" position="replace">
希望这会有所帮助。
在 Odoo 10 中,我试图用 xpath 表达式替换此模板的内容。我想要做的只是 select 第一个 "Weight" 并将其替换为 "test"
<odoo>
<template id="report_delivery_document2" inherit_id="stock.report_delivery_document">
<xpath expr="//th[@name='td_sched_date_h']" position="after">
<th t-if="o.picking_type_id.code == 'outgoing' and o.carrier_id"><strong>Carrier</strong></th>
<th t-if="o.weight"><strong>Weight</strong></th>
</xpath>
<xpath expr="//td[@name='td_sched_date']" position="after">
<td t-if="o.picking_type_id.code == 'outgoing' and o.carrier_id">
<span t-field="o.carrier_id"/>
</td>
<td t-if="o.weight">
<span t-field="o.weight"/>
<span t-field="o.weight_uom_id"/>
</td>
</xpath>
</template>
在我的模块中,我正在尝试这段代码:
<odoo>
<template id="report_delivery_document3" inherit_id="stock_delivery_slip.report_sale_delivery_slip_createch">
<!-- <xpath expr="//th[contains(., 'Weight')]" position="replace"> -->
<!-- <xpath expr="//th/strong[text()='Weight']" position="replace"> -->
<th>test</th>
<!-- </xpath> -->
</template>
但是没有任何效果,我怎么能 select "Weight" 而不在 "report_delivery_document2" 中添加属性?
提前致谢。
您只需编辑该视图 (report_delivery_document2) 的翻译,然后更改:
<strong>Weight</strong>
进入:
<strong>test</strong>
但是如果你想保留 xpath,只需这样做:
<xpath expr="//th[@t-if='o.weight']" position="replace">
希望这会有所帮助。