[FIX] Account: historical currency rate support

lp bug: https://launchpad.net/bugs/591961 fixed

bzr revid: mra@mra-laptop-20101125115838-nsx04bclby615iaw
This commit is contained in:
RVO(OpenERP) 2010-11-25 17:28:38 +05:30 committed by Mustufa Rangwala
parent 55ef479cf0
commit df57bcc6b6
1 changed files with 5 additions and 2 deletions

View File

@ -541,7 +541,9 @@ class account_move_line(osv.osv):
]
#TODO: ONCHANGE_ACCOUNT_ID: set account_tax_id
def onchange_currency(self, cr, uid, ids, account_id, amount, currency_id, date=False, journal=False):
def onchange_currency(self, cr, uid, ids, account_id, amount, currency_id, date=False, journal=False, context=None):
if context is None:
context = {}
account_obj = self.pool.get('account.account')
journal_obj = self.pool.get('account.journal')
currency_obj = self.pool.get('res.currency')
@ -552,7 +554,8 @@ class account_move_line(osv.osv):
if (amount>0) and journal:
x = journal_obj.browse(cr, uid, journal).default_credit_account_id
if x: acc = x
v = currency_obj.compute(cr, uid, currency_id, acc.company_id.currency_id.id, amount, account=acc)
context.update({'date': date})
v = currency_obj.compute(cr, uid, currency_id, acc.company_id.currency_id.id, amount, account=acc, context=context)
result['value'] = {
'debit': v > 0 and v or 0.0,
'credit': v < 0 and -v or 0.0