Merge lp:~openerp-dev/openobject-addons/7.0-opw-606679-jam into lp:openobject-addons/7.0

Proposed by Jigar A.
Status: Needs review
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-opw-606679-jam
Merge into: lp:openobject-addons/7.0
Diff against target: 20 lines (+2/-1)
1 file modified
product/product.py (+2/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-opw-606679-jam
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+216189@code.launchpad.net

Description of the change

UOM conversion leads to the wrong stock count, Using ceiling or mathematical round for the UOM conversion is too risky and it leads to the extra stock counting. As Uom rounding field store the random values after 13 decimal values(Floating Point Arithmetic issue) so using the ceiling and openerp rounding values lead to wrong values and in case of stock counting this create extra stock entries.

Story:
- Create Unit of Measure : 12/CASE, under Unit category with Larger then base with Rounding Precision 0.010 and Ratio 12.000000000000 but actually it will store as 12.000000000048.
- Create a Product "Router R430" with Units as base UOM.
- Create the Purchase Order with 9 qty, UOM = 12/CASE, confirm and receive them.
- Check Quantity On Hand and Forecasted Quantity which will be shown 109 instead of 108. This is case of ceiling rounding.

Kindly review this
Thanks

To post a comment you must log in.

Unmerged revisions

9990. By Jigar A.

[FIX] product: When converting unit of mesures, round using the float_round util instead of above(ceiling Ravno#9197) or mathematical rounding

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'product/product.py'
2--- product/product.py 2014-03-05 17:14:56 +0000
3+++ product/product.py 2014-04-16 18:37:57 +0000
4@@ -27,6 +27,7 @@
5 from openerp import tools
6 from openerp.osv import osv, fields
7 from openerp.tools.translate import _
8+from openerp.tools import float_round
9
10 import openerp.addons.decimal_precision as dp
11
12@@ -178,7 +179,7 @@
13 return qty
14 amount = qty / from_unit.factor
15 if to_unit:
16- amount = ceiling(amount * to_unit.factor, to_unit.rounding)
17+ amount = float_round(amount * to_unit.factor, precision_rounding = to_unit.rounding)
18 return amount
19
20 def _compute_price(self, cr, uid, from_uom_id, price, to_uom_id=False):