Search code examples
pythonpython-3.xodooroundingodoo-14

Odoo currency rounding with too many decimals


I am trying to convert one currency float to another, but for some reason the resulting number (even though it is correct) has too many decimals.

I am converting EUR float 36.75 (currency decimal rounding = 0.01) into CZK float (currency decimal rounding = 0.01)

Example

eur_currency._convert(36.75, move.company_currency_id, move.company_id, move.date)

result = 942.3100000000001

desired output = 942.31


Solution

  • You can use round:

    round(result, 2)