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):