繁体   English   中英

Odoo 10中的Xpath contains()

[英]Xpath contains() in Odoo 10

在Odoo 10中,我试图用xpath表达式替换此模板的内容。 我想做的只是选择第一个为“ 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>

但是没有任何效果,如何在“ report_delivery_document2”中不添加属性的情况下选择“ Weight”?

提前致谢。

您可以简单地编辑该视图的翻译(report_delivery_document2),然后更改:

<strong>Weight</strong>

进入:

<strong>test</strong>

但是,如果要保留xpath,请执行以下操作:

<xpath expr="//th[@t-if='o.weight']" position="replace">

希望这会有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM