Merge lp:~matjaz-6/openerpsl/openerpsl_02_17 into lp:openerpsl/7.0

Proposed by Matjaz Kalic
Status: Merged
Merged at revision: 394
Proposed branch: lp:~matjaz-6/openerpsl/openerpsl_02_17
Merge into: lp:openerpsl/7.0
Diff against target: 52 lines (+31/-9)
1 file modified
mrp_procurement_qty/product.py (+31/-9)
To merge this branch: bzr merge lp:~matjaz-6/openerpsl/openerpsl_02_17
Reviewer Review Type Date Requested Status
Mentis Pending
Review via email: mp+217026@code.launchpad.net

Description of the change

[FIX] product_obj (_compute_qty_obj rounding problem)

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'mrp_procurement_qty/product.py'
2--- mrp_procurement_qty/product.py 2014-04-14 08:29:52 +0000
3+++ mrp_procurement_qty/product.py 2014-04-24 11:02:52 +0000
4@@ -83,18 +83,40 @@
5
6 product_product()
7
8+def true_rounding(f, r):
9+ if not r:
10+ return f
11+
12+ _index = r
13+ _count = 0
14+
15+ while _index % 1 > 0:
16+ _index = _index * 10
17+ _count += 1
18+
19+ _result = round(f / r) * r
20+ _result = round(_result, _count)
21+
22+ return _result
23+
24 class product_uom(osv.osv):
25 _inherit = 'product.uom'
26
27- def _compute_qty(self, cr, uid, from_uom_id, qty, to_uom_id=False):
28- res = super(product_uom, self)._compute_qty(cr, uid, from_uom_id=from_uom_id, qty=qty, to_uom_id=to_uom_id)
29- res_rounded = round(res, 2)
30-
31- #temp={}
32- #temp[0] = res
33- #temp[1] = res_rounded
34-
35- return res_rounded
36+# def _compute_qty(self, cr, uid, from_uom_id, qty, to_uom_id=False):
37+# res = super(product_uom, self)._compute_qty(cr, uid, from_uom_id=from_uom_id, qty=qty, to_uom_id=to_uom_id)
38+# res_rounded = round(res, 2)
39+#
40+# temp={}
41+# temp[0] = res
42+# temp[1] = res_rounded
43+#
44+# return res_rounded
45+ def _compute_qty_obj(self, cr, uid, from_unit, qty, to_unit, context=None):
46+ res = super(product_uom, self)._compute_qty_obj(cr, uid, from_unit=from_unit, qty=qty, to_unit=to_unit, context=context)
47+
48+ if to_unit:
49+ res = true_rounding(res * to_unit.factor, to_unit.rounding)
50+ return res
51
52 product_uom()
53

Subscribers

People subscribed via source and target branches