Hello, I would like to change invoices to see 2 digits in the decimal part. Do you have a xml file becouse I am going to make a new modulo.
Thanks so much.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello, I would like to change invoices to see 2 digits in the decimal part. Do you have a xml file becouse I am going to make a new modulo.
Thanks so much.
Hai,
You can use the t-esc or t-field tag with Python formatting like this:
xml Codes:
<t t-esc="'%.2f' % line.price_unit"/>
<t t-esc="'%.2f' % line.price_total"/>
This will round the number to 2 decimal places when rendering the invoice.
Example in Your Custom Module:
If you're creating a new module, you can inherit and override the invoice report template like this:
<odoo>
<template id="report_invoice_document_custom" inherit_id="account.report_invoice_document">
<xpath expr="//t[@t-field='line.price_unit']" position="replace">
<t t-esc="'%.2f' % line.price_unit"/>
</xpath>
<xpath expr="//t[@t-field='line.price_total']" position="replace">
<t t-esc="'%.2f' % line.price_total"/>
</xpath>
</template>
</odoo>
Hi,
Yes, you can show only 2 decimal places on your invoice PDF by overriding the QWeb template in a custom module. Here's a simple XML example you can use:
xml file:
<odoo>
<template id="report_invoice_2decimals" inherit_id="account.report_invoice_document">
<!-- Unit Price -->
<xpath expr="//span[@t-field='line.price_unit']" position="attributes">
<attribute name="t-options">{'widget': 'float', 'precision': 2}</attribute>
</xpath>
<!-- Subtotal -->
<xpath expr="//span[@t-field='line.price_subtotal']" position="attributes">
<attribute name="t-options">{'widget': 'float', 'precision': 2}</attribute>
</xpath>
<!-- Total -->
<xpath expr="//span[@t-field='o.amount_total']" position="attributes">
<attribute name="t-options">{'widget': 'float', 'precision': 2}</attribute>
</xpath>
</template>
</odoo>
Add this XML file inside your custom module under the views/ folder and include it in your __manifest__.py file like this:
'data': [
'views/report_invoice_2decimals.xml',
],
Then restart Odoo and upgrade your module. Now your invoice PDF will display all amounts with 2 decimal places.
Hope it helps.
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ý