Fix currency compute
authorced <>
Fri, 29 Dec 2006 14:53:32 +0000 (14:53 +0000)
committerced <>
Fri, 29 Dec 2006 14:53:32 +0000 (14:53 +0000)
bzr revid: ced-c85a8f2daeddb246ab82f8eae7ff52f489f086a0

bin/addons/base/res/res_currency.py

index d4a82c6..3c59527 100644 (file)
@@ -67,14 +67,17 @@ class res_currency(osv.osv):
        def round(self, cr, uid, currency, amount):
                return round(amount / currency.rounding) * currency.rounding
 
-       def compute(self, cr, uid, from_currency_id, to_currency_id, from_amount):
+       def compute(self, cr, uid, from_currency_id, to_currency_id, from_amount, round=True):
                if to_currency_id==from_currency_id:
                        return from_amount
-               [from_currency]=self.read(cr, uid, [from_currency_id])
-               [to_currency] = self.read(cr, uid, [to_currency_id])
+               from_currency=self.browse(cr, uid, [from_currency_id])[0]
+               to_currency = self.browse(cr, uid, [to_currency_id])[0]
                if from_currency['rate'] == 0 or to_currency['rate'] == 0:
                        raise osv.except_osv('Error', 'No rate found for the currency')
-               return self.round(cr, uid, to_currency, from_amount * from_currency['rate']/to_currency['rate'])
+               if round:
+                       return self.round(cr, uid, to_currency, from_amount * from_currency.rate/to_currency.rate)
+               else:
+                       return (from_amount * from_currency.rate/to_currency.rate)
 res_currency()
 
 class res_currency_rate(osv.osv):