ACCOUNT: add multi-company into base accounting
bzr revid: mga@tinyerp.com-9e23cf4c3f00f3254ccf656a07650a7a97eed0da
This commit is contained in:
parent
c5b1fbc478
commit
c08880036b
|
@ -72,19 +72,23 @@ class res_currency(osv.osv):
|
|||
return round(amount / currency.rounding) * currency.rounding
|
||||
|
||||
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
|
||||
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]
|
||||
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:
|
||||
return self.round(cr, uid, to_currency, from_amount * from_currency.rate/to_currency.rate)
|
||||
if to_currency_id==from_currency_id:
|
||||
if round:
|
||||
return self.round(cr, uid, to_currency, from_amount)
|
||||
else:
|
||||
return from_amount
|
||||
else:
|
||||
return (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