Dear all,
I am using Odoo 12 and having problems on using xpath for 2 expressions.
The original code for the views I want to inherit and replace are:
1.
<t t-foreach="payments_vals" t-as="payment_vals">
<tr>
<td>
<i class="oe_form_field text-right oe_payment_label">Paid on <t t-esc="payment_vals['date']"/></i>
</td>
<td class="text-right">
<span t-esc="payment_vals['amount']" t-options='{"widget": "monetary", "display_currency": o.currency_id}'/>
</td>
</tr>
</t>
2.
<t t-if="len(payments_vals) > 0">
<tr class="border-black">
<td>
<strong>Amount Due</strong>
</td>
<td class="text-right">
<span t-field="o.residual"/>
</td>
</tr>
</t>
On the first code I want to use xpath to locate: <t t-foreach="payments_vals" t-as="payment_vals">
On the second case, I want to use xpath to locate: <t t-if="len(payments_vals) > 0">
Can anyone help me please?
Thank you all in advance
Best regards
PM
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
Hello Paulo Matos,
Try below code, it will work in my case so it will help you.
<template id="report_invoice_payments" inherit_id="account.report_invoice_document_with_payments">
<xpath expr="//t[2]/tr" position="replace">
<tr>
do you custom code here ....
</tr>
</xpath>
<xpath expr="//t[3]/tr" position="replace">
<tr class="border-black">
do you custom code here ....
</tr>
</xpath>
</template>
-------
Thanks
Sunny Sheth
Please try this.
1.
<xpath expr="//t[@t-foreach='payments_vals']" position="after">
<field name="field_name" string="custom_field"/>
</xpath>
2.
<xpath expr="//t[@t-if='len(payments_vals) > 0']" position="after">
<field name="field_name" string="custom_field"/>
</xpath
Hi @Sugeesh Ps
I have tried both options with position='replace' because want to replace the full code inside but it does not work.
Odoo cannot locate the expression and I am sure I am inheriting the correct xlm id.
I think the problem is related to the fact that each expression have more data inside of it... ie. <t t-foreach="payments_vals" t-as="payment_vals">... is not just 'payment_vals'.
Regards
PM
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
3
thg 10 23
|
8623 | ||
|
1
thg 9 23
|
3241 | ||
|
1
thg 5 23
|
2209 | ||
|
2
thg 4 23
|
2733 | ||
Inherit Element form kanban View
Đã xử lý
|
|
1
thg 3 23
|
2137 |