Change Uom.round into an instance method.

issue4423
review19651002
This commit is contained in:
Karla Stenger committed 2016-01-11 10:28:00 -03:00
1 parent 171fb6cb73
commit 8b7f208e9c
3 files changed
+5 -4

No files matched your search

+1
View File
@@ -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
+1 -1
View File
@@ -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():
+3 -3
View File
@@ -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