Multi-Currencies code

bzr revid: fp@tinyerp.com-528dab59710d2dd717e8a7895e12222364d78c30
This commit is contained in:
Fabien Pinckaers 2007-03-27 08:25:19 +00:00
parent afe05425d8
commit aae8550ac5
1 changed files with 5 additions and 2 deletions

View File

@ -74,8 +74,11 @@ class res_currency(osv.osv):
def compute(self, cr, uid, from_currency_id, to_currency_id, from_amount, round=True, context={}):
if to_currency_id==from_currency_id:
return from_amount
from_currency=self.browse(cr, uid, [from_currency_id], context=context)[0]
to_currency = self.browse(cr, uid, [to_currency_id], context=context)[0]
if not from_currency_id:
from_currency_id = to_currency_id
xc=self.browse(cr, uid, [from_currency_id,to_currency_id], context=context)
from_currency = xc[0].id == from_currency_id and xc[0] or xc[1]
to_currency = xc[0].id == to_currency_id and xc[0] or xc[1]
if from_currency['rate'] == 0 or to_currency['rate'] == 0:
raise osv.except_osv('Error', 'No rate found for the currency')
if round: