From a2dc2edbc055f0297504f33a1040bb71fbc90c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 3 Nov 2008 15:39:40 +0100 Subject: [PATCH] Add options on compute_qty to round or not --- uom.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/uom.py b/uom.py index 47e49fe0d6..0c3b628046 100644 --- a/uom.py +++ b/uom.py @@ -138,7 +138,7 @@ class Uom(OSV): return super(Uom, self).write(cursor, user, ids, values, context) def compute_qty(self, cursor, user, from_uom, qty, to_uom=False, - context=None): + round=True, context=None): """ Convert quantity for given uom's. from_uom and to_uom should be browse records. @@ -153,9 +153,11 @@ class Uom(OSV): amount = qty / from_uom.rate if to_uom: if to_uom.factor >= 1.0: - amount = self.round(amount / to_uom.factor, to_uom.rounding) + amount = amount / to_uom.factor else: - amount = self.round(amount * to_uom.rate, to_uom.rounding) + amount = amount * to_uom.rate + if round: + amount = self.round(amount, to_uom.rounding) return amount def compute_price(self, cursor, user, from_uom, price, to_uom=False,