Floating Point / Rounding issue in stock partial picking wizard
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Odoo Addons (MOVED TO GITHUB) |
Fix Released
|
Medium
|
OpenERP R&D Addons Team 2 | ||
6.0 |
Confirmed
|
Medium
|
OpenERP Publisher's Warranty Team |
Bug Description
We encountered an Floating Point rounding issue, in the Partial Picking wizard (stock/
"Processing quantity 390.268 kg for $PRODUCT is larger than the available quantity 390.268 kg."
(Decimal Precision of Product UoM is set to 3, UoM Rounding for kg is 0.001)
OK, so I added an output of the test
if calc_qty > move.move_
390.268 > 390.268
As one would say, 390.268 > 390.268 should be false...
But:
calc_qty - move.move_
This is beyond the default python %s rounding of 6 decimals (to understand the 390.268 > 290.268 output above)
So here is a real problem with rounding precision and float (instead of decimal) data type.
I changed the query to regard decimal precision:
prec = dp.get_
if int(calc_qty * (10**prec)) > int(move.
and it works fine.
Related branches
- Raphael Collet (OpenERP) (community): Needs Fixing
- Hardik Ansodariya (OpenERP): Pending requested
-
Diff: 72 lines (+12/-5)2 files modifiedsale/sale.py (+3/-2)
stock/stock.py (+9/-3)
Changed in openobject-addons: | |
assignee: | nobody → OpenERP Publisher's Warranty Team (openerp-opw) |
tags: | added: maintenance |
Changed in openobject-addons: | |
status: | Confirmed → In Progress |
tags: | added: ocb-stock-v1 |
no longer affects: | ocb-addons |
hello
wouldn't round(a,precision) = round(b,precision) do it ?
and
this is a potential trap for every float comparison ( ==, != ) which is based on python calculated values