diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index a7c7646f6e1..ce6a35adb32 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -1055,7 +1055,8 @@ class account_voucher(osv.osv): 'period_id': voucher.period_id.id, 'partner_id': voucher.partner_id.id, 'currency_id': company_currency <> current_currency and current_currency or False, - 'amount_currency': company_currency <> current_currency and sign * voucher.amount or 0.0, + 'amount_currency': (sign * abs(voucher.amount) # amount < 0 for refunds + if company_currency != current_currency else 0.0), 'date': voucher.date, 'date_maturity': voucher.date_due } @@ -1217,7 +1218,7 @@ class account_voucher(osv.osv): if line.amount == line.amount_unreconciled: if not line.move_line_id: raise osv.except_osv(_('Wrong voucher line'),_("The invoice you are willing to pay is not valid anymore.")) - sign = voucher.type in ('payment', 'purchase') and -1 or 1 + sign = line.type =='dr' and -1 or 1 currency_rate_difference = sign * (line.move_line_id.amount_residual - amount) else: currency_rate_difference = 0.0 @@ -1275,8 +1276,7 @@ class account_voucher(osv.osv): # otherwise we use the rates of the system amount_currency = currency_obj.compute(cr, uid, company_currency, line.move_line_id.currency_id.id, move_line['debit']-move_line['credit'], context=ctx) if line.amount == line.amount_unreconciled: - sign = voucher.type in ('payment', 'purchase') and -1 or 1 - foreign_currency_diff = sign * line.move_line_id.amount_residual_currency + amount_currency + foreign_currency_diff = line.move_line_id.amount_residual_currency - abs(amount_currency) move_line['amount_currency'] = amount_currency voucher_line = move_line_obj.create(cr, uid, move_line)