Odoo Help


Should Odoo be using decimal.Decimal for rounding precision?

George Mengelberg
on 10/30/14, 10:54 AM 3,347 views

Based on the following, it seems as though Decimal is a more appropriate type to 
use when dealing with currency and accounting data.  Is there reason to be 
concerned about rounding accuracy in Odoo?




| 5 4 6
Zagreb | Karlovac, Croatia

there is only 10 kind of people the ones that understand binary ... and others

On 10/30/14, 11:17 AM

Your statement is true.. decimal indeed is better for accounting and financial number representation
But whole odoo ( ex openerp, ex-ex tiny erp) orm is developed on float numbers, there is a number of tools developed to handle floating numbers in odoo /openerp (check openerp/tools/float_utils.py ...) and you just need to learn how to use it and will probably not get into problems with floating point number rounding accuracy... The reason for this decision is most likely overall speed... 
Math functions with float numbers are way faster than with decimal... 

On the other hand.. if you are so eager to use decimal numbers ( and once again i agree it is more precise ) .. you can try using tryton...
wich is a fork of tiny erp  and wich is completly based on decimal numbers... 

i will not post link to it on this forum, but our old friend google mingt know a site or two that will clearify this issue a bit more... 

as for me... i'll stick to odoo even if it is based on float numbers... 
you just need to be aware what you are doing...

p.s. i have encountered problem with acuracy and number represenation a few times....
and found an easy and fast workaround  : i let postgres do the math instead of python... (just write correct sql)
it is fast and accurate... (with no floating point problems) :) 


Bole, Thanks for the response. I ran into rounding problems as well but, at the time, I could not find a good work around.

George Mengelberg
on 10/30/14, 8:12 PM

George, I think you'll run into rounding problems whether or not you use Decimal. Consider if you have multiple figures to sum with decimal points. You may have a different result if you round the figures first then sum compared to if you sum the figures first then round. For the most part Odoo has tried to be very careful in those calculation. For instance, In Odoo, Invoice Tax is calculated from Invoice Line's Subtotal which is discounted first. In my country discount is applied to the Invoice's total, not individual lines. This difference has pose some interesting cases in my project when dealing with Invoice figures that are rounded.

on 10/31/14, 9:23 AM

Ben Bernard

--Ben Bernard--

| 4 3 6
Jakarta, Indonesia
--Ben Bernard--
Ben Bernard
On 10/31/14, 12:23 AM

For me, the solution is to know when to round amount currency. I set 10 for decimal precision rate (because IDR/USD) and do floating point calculation. At the end round the amount to decimal precision already defined (2, for example).


About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 10/30/14, 10:54 AM
Seen: 3347 times
Last updated: 3/16/15, 8:10 AM