[IMP] account: display payment amount in its own currency

The payment widget now displays the payment in its currency, not in the
currency of the invoice.

opw-652747
This commit is contained in:
Nicolas Martinelli
2015-11-06 14:53:53 +01:00
parent 2c727cd852
commit 8a05e585d8
+9 -8
View File
@@ -137,28 +137,29 @@ class AccountInvoice(models.Model):
if self.payment_move_line_ids:
info = {'title': _('Less Payment'), 'outstanding': False, 'content': []}
for payment in self.payment_move_line_ids:
#we don't take into account the movement created due to a change difference
if payment.currency_id and payment.move_id.rate_diff_partial_rec_id:
continue
if self.type in ('out_invoice', 'in_refund'):
amount = sum([p.amount for p in payment.matched_debit_ids if p.debit_move_id in self.move_id.line_ids])
amount_currency = sum([p.amount_currency for p in payment.matched_debit_ids if p.debit_move_id in self.move_id.line_ids])
elif self.type in ('in_invoice', 'out_refund'):
amount = sum([p.amount for p in payment.matched_credit_ids if p.credit_move_id in self.move_id.line_ids])
amount_currency = sum([p.amount_currency for p in payment.matched_credit_ids if p.credit_move_id in self.move_id.line_ids])
#we don't take into account the movement created due to a change difference
if payment.currency_id and payment.move_id.rate_diff_partial_rec_id:
continue
# get the payment value in invoice currency
if payment.currency_id and amount_currency != 0:
currency_id = payment.currency_id
amount_to_show = -amount_currency
else:
self.with_context(date=payment.date)
amount_to_show = payment.company_id.currency_id.compute(-amount, self.currency_id)
currency_id = payment.company_id.currency_id
amount_to_show = -amount
info['content'].append({
'name': payment.name,
'journal_name': payment.journal_id.name,
'amount': amount_to_show,
'currency': self.currency_id.symbol,
'digits': [69, self.currency_id.decimal_places],
'position': self.currency_id.position,
'currency': currency_id.symbol,
'digits': [69, currency_id.decimal_places],
'position': currency_id.position,
'date': payment.date,
'payment_id': payment.id,
'move_id': payment.move_id.id,