invoice create returns error : You cannot validate a non-balanced entry (rounding error)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Addons (MOVED TO GITHUB) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
After upgrading to 5.0.6 a client now runs into this problem,
Some combinations of products ( with taxes and discounts ) give the error
"Integrity Error ! You can not validate a non-balanced entry !"
Invoicing the products separately never gave an issue either.
After some debugging it turned out that the accumulated rounding error was larger than 0.0001 (see account.py:1024 in stable branch)
-> if abs(amount) < 0.0001:
(Pdb) amount
-0.009999999999
I think this line should be changed to following
if abs(amount) < ( 1.0 / ( int(config[
*note*: beware the parentheses, it seems python has an issue with 1.0 / 2 * 10 being 5 (so it's not multiplying before dividing)
I think the reason it's now happening in 5.0.6 is because in the accounting more changes to honor the config[ 'price_ accuracy' ] variable, so in various places it's already trying to round more correctly ?
Strangely enough my price_accuracy should have always been 2 as well, so I could be wrong with this hunch.