Hi all,
On our Odoo instance, some articles are in kilograms, litters and units. We may sometime order/sale a few milliliters or grams of some articles. The Decimal Accuracy setting was adjusted to 4 digits for Product Unit of Measure. The drawback is that for articles in "Units", all values expected to be integers are also displayed with 4 digits after decimal. Ex. 20.0000 carrots for 20 carrots. For internal use, that's not a really issue. Nevertheless, be become an issue when dealing with order forms, invoices, etc.
To address this issue, I undertook to develop an add-on to modify the report_saleorder_document QWeb report defined for the template named sale.report_saleorder to display l.product_uom_qty as an integer when l.product_uom is set to "Unit(s)", else as a float.
My template.xml looks like :
<template id="report_saleorder_document" inherit_id="sale.report_saleorder_document">
<xpath expr="//span[@t-field='l.product_uom_qty']" position="replace">
<t t-set="unit" t-value="l.product_uom"/>
[<t t-esc="unit" />]
<span t-if="unit == 'product.uom(1,)'" t-esc="int(l.product_uom_qty)"/>
<span t-else="" t-field="l.product_uom_qty"/>
<!-- <span t-field="l.product_uom" groups="product.group_uom"/> -->
</xpath>
</template>
This display [product.uom(1,)] for [<t t-esc="unit" />]
But the test t-if="unit == 'product.uom(1,)'" fails. It seems QWeb tries to interpret/execute product.uom(1,) as it would do for any other function and do not use it as a literal string.
Would you have a solution in order address this simple need : display quantity as an integer when articles is in Units, display as a regular float else?
Thanks.
Maxime.