diff --git a/CHANGELOG b/CHANGELOG index b6632ecb96..b3a193282c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Change Uom.round into an instance method * Add Function fields on Product from Template Version 3.8.0 - 2015-11-02 diff --git a/tests/test_product.py b/tests/test_product.py index ec5048ce2e..c0fa072d35 100644 --- a/tests/test_product.py +++ b/tests/test_product.py @@ -311,7 +311,7 @@ class ProductTestCase(ModuleTestCase): pool = Pool() Uom = pool.get('product.uom') for number, precision, result in tests: - self.assertEqual(Uom.round(number, precision), result) + self.assertEqual(Uom(rounding=precision).round(number), result) def suite(): diff --git a/uom.py b/uom.py index 4b3945d57d..cdaa26cfd0 100644 --- a/uom.py +++ b/uom.py @@ -134,8 +134,8 @@ class Uom(ModelSQL, ModelView): ('symbol',) + tuple(clause[1:]), ] - @staticmethod - def round(number, precision=1.0): + def round(self, number): + precision = self.rounding i, d = divmod(precision, 1) base = round(number / precision) # Instead of multiply by the decimal part, we must divide by the @@ -232,7 +232,7 @@ class Uom(ModelSQL, ModelView): amount = amount * to_uom.rate if round: - amount = cls.round(amount, to_uom.rounding) + amount = to_uom.round(amount) return amount