I am trying to manage the following behaviour in Odoo 8:
Set a product price of 5 decimals. For that, I set decimal accuracy of Product Price to 5.
In sale.order
view, show only 3 decimals, but calculate the subtotal of the line taking into account the 5 decimals. For this step, I am modifying the view to put this on price_unit
field:
<xpath expr="//field[@name='order_line']/tree/field[@name='price_unit']" position="replace">
<field name="price_unit" digits="(16,3)"/>
</xpath>
But that digits
attribute is altering the result.
Example:
I store a product with price 1,00123. I add 5 units of it on a sale order. If I do not use
digits
in the XML view, the subtotal is 5,01. Because 1,00123 * 5 = 5,00615, rounding this to Account Accuracy (2 decimals) gives 5,01. But if I use digits in XML view, the subtotal is 5,00. Because 1,001 * 5 = 5,005, rounding this to Account Accuracy (2 decimals) gives 5,00.In fact, I show with logger the
line.price_unit
value insale.order.line
method_calc_line_base_price
. With digits in XML view,line.price_unit
values 1,001, without it, it gives 1,00123.
Can anyone tell me how could I show 3 decimals for price unit in XML view without altering the decimal accuracy of 5 decimals? It must be done only for visualization.
If the xml digits
are indeed taken into account for calculations (can't verify that at the moment), you can always have two fields - hidden one for calculations with maximum accuracy, and another for display purposes, which displays already calculated numbers with specified accuracy.