From 2b52dda423c19bc443209de2aea7874715201a51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 3 Nov 2008 15:41:04 +0100 Subject: [PATCH] Round quantities only once --- product.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/product.py b/product.py index 2ba5ae54c2..7add9b930c 100644 --- a/product.py +++ b/product.py @@ -308,7 +308,8 @@ class Product(OSV): key = (location, product) res.setdefault(key, 0.0) res[key] += uom_obj.compute_qty(cursor, user, uom_by_id[uom], - quantity, default_uom[product], context=context) + quantity, default_uom[product], round=False, + context=context) # Propagate quantities on from child locations to their parents if with_childs: @@ -344,6 +345,13 @@ class Product(OSV): if location not in location_ids: del res[(location, product)] + # Round quantities + for location, product in res: + key = (location, product) + res[key] = uom_obj.compute_qty(cursor, user, default_uom[product], + res[key], default_uom[product], round=True, + context=context) + # Complete result with missing products if asked if not skip_zero: keys = ((l,p) for l in location_ids for p in product_ids)