如何在此位置内提供 xpath 。
<div t-attf-id="o_payment_form_acq_{{acq.id}}" t-attf-class="hidden {{'panel-footer' if acq.save_token == 'ask' else ''}}">
我尝试了以下操作,但它出错了:
<template id="stripe_form_type" inherit_id="payment.payment_tokens_list">
<xpath expr="//div[hasid('o_payment_form_acq_{{acq.id}}')]" position="after">
<div>hello</div>
</xpath>
</template>
答案 0 :(得分:0)
也许试试
<template id="stripe_form_type" inherit_id="payment.payment_tokens_list">
<xpath expr="//div[@t-attf-id='o_payment_form_acq_{{acq.id}}']" position="after">
<div>hello</div>
</xpath>
</template>
当难以获取元素时,我使用相对路径。您想要获取的元素包含inout元素。
<div t-attf-id="o_payment_form_acq_{{acq.id}}" t-attf-class="hidden {{'panel-footer' if acq.save_token == 'ask' else ''}}">
<label t-if="acq.save_token == 'ask'"><input type="checkbox" name="o_payment_form_save_token" data-remove-me=""/> Save my payment data</label>
</div>
所以你可以使用这段代码获得它
<template id="stripe_form_type" inherit_id="payment.payment_tokens_list">
<xpath expr="//input[@name='o_payment_form_save_token']/.." position="after">
<div>hello</div>
</xpath>
</template>