summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin (OpenERP) <qdp-launchpad@openerp.com>2013-04-23 15:50:28 +0200
committerQuentin (OpenERP) <qdp-launchpad@openerp.com>2013-04-23 15:50:28 +0200
commit2bc4260c545dca24a1ea4f92dd52ac548a577b0e (patch)
treee5c78961f638f21677789ac3307a03bc96d5748c
parent7e462604747f4f9bd8668732b9cdae72d8613fd2 (diff)
[FIX] account_voucher: fix in amount_currency computation when the rate is specified on the voucher and the voucher is in the company currency
bzr revid: qdp-launchpad@openerp.com-20130423135028-70887smme8mxv0tn
-rw-r--r--addons/account_voucher/account_voucher.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py
index dd8bb157067..9e0e7e5b167 100644
--- a/addons/account_voucher/account_voucher.py
+++ b/addons/account_voucher/account_voucher.py
@@ -1167,8 +1167,13 @@ class account_voucher(osv.osv):
amount_currency = sign * (line.amount)
elif line.move_line_id.currency_id.id == voucher_brw.payment_rate_currency_id.id:
# if the rate is specified on the voucher, we must use it
- voucher_rate = currency_obj.browse(cr, uid, voucher_currency, context=ctx).rate
- amount_currency = (move_line['debit'] - move_line['credit']) * voucher_brw.payment_rate * voucher_rate
+ payment_rate = voucher_brw.payment_rate
+ if voucher_currency != company_currency:
+ #if the voucher currency is not the company currency, we need to consider the rate of the line's currency
+ voucher_rate = currency_obj.browse(cr, uid, voucher_currency, context=ctx).rate
+ payment_rate = voucher_rate * payment_rate
+ amount_currency = (move_line['debit'] - move_line['credit']) * payment_rate
+
else:
# otherwise we use the rates of the system (giving the voucher date in the context)
amount_currency = currency_obj.compute(cr, uid, company_currency, line.move_line_id.currency_id.id, move_line['debit']-move_line['credit'], context=ctx)