This question has been flagged
2 Replies
8109 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?
http://chimera.labs.oreilly.com/books/1230000000393/ch03.html#_solution_42

Avatar
Discard
Best Answer

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) :) 


 

Avatar
Discard
Author

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, 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.

Best Answer

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).

 

Avatar
Discard