Comment 96 for bug 452854

Revision history for this message
Olivier Dony (Odoo) (odo-openerp) wrote : Re: [Bug 452854] Re: Cannot validate invoices with foreign currency

On 27/04/10 19:46, Borja López Soilán (Pexego) wrote:
> But... shouldn't it better be "if abs(amount) < 0.5 * 10
> **-(int(config['price_accuracy'])):"?
> (...)
> I mean, on the original version, an amount like 0.009 would pass the test, but afterwards it could be rounded to 0.01 causing havoc*
> * For an account move with two lines: 10.09 on the debit, 10.08 on the credit (unbalanced!), Python calculates a difference as 0.0099999999999997868 (that is less than 0.01!).
>
> Your patch prevents this, but also means that an amount like 0.002 will
> not pass even when it would be rounded to 0.00 on the move lines!

Technically you're right, but I think we don't need to allow it because
a difference of 0.002 is not supposed to happen if the rounding has been
done correctly on each line.
So to be on the safe side we prevent it completely.

Do you have a working example of a move that contains *balanced* and
*rounded* lines but that would not pass this test?

BTW if you look at the history this check used to be hardcorded to:
    abs(amount) < 0.0001
in all cases.