Fix currency compute
bzr revid: ced-c85a8f2daeddb246ab82f8eae7ff52f489f086a0
This commit is contained in:
parent
ae9ff0f6c5
commit
a3ff2c72e2
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue