Change Uom.round into an instance method.
issue4423 review19651002
This commit is contained in:
1 parent
171fb6cb73
commit
8b7f208e9c
3 files changed
+5
-4
No files matched your search
@@ -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
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in new issue
Block a user