[FIX] account, website_portal_sale: _generate_and_pay_invoice in other currency
When paying in other currency that the one defined in the company, it generates a payment which has to be in the currency of the transaction. Otherwise it will generate an invoice which won't be completely paid. opw:769278
This commit is contained in:
@@ -1113,7 +1113,7 @@ class AccountInvoice(models.Model):
|
||||
if self.origin:
|
||||
communication = '%s (%s)' % (communication, self.origin)
|
||||
|
||||
payment = self.env['account.payment'].create({
|
||||
payment_vals = {
|
||||
'invoice_ids': [(6, 0, self.ids)],
|
||||
'amount': pay_amount or self.residual,
|
||||
'payment_date': date or fields.Date.context_today(self),
|
||||
@@ -1125,7 +1125,11 @@ class AccountInvoice(models.Model):
|
||||
'payment_method_id': payment_method.id,
|
||||
'payment_difference_handling': writeoff_acc and 'reconcile' or 'open',
|
||||
'writeoff_account_id': writeoff_acc and writeoff_acc.id or False,
|
||||
})
|
||||
}
|
||||
if self.env.context.get('tx_currency_id'):
|
||||
payment_vals['currency_id'] = self.env.context.get('tx_currency_id')
|
||||
|
||||
payment = self.env['account.payment'].create(payment_vals)
|
||||
payment.post()
|
||||
|
||||
return True
|
||||
|
||||
@@ -29,7 +29,7 @@ class PaymentTransaction(models.Model):
|
||||
|
||||
created_invoice.action_invoice_open()
|
||||
if tx.acquirer_id.journal_id:
|
||||
created_invoice.pay_and_reconcile(tx.acquirer_id.journal_id, pay_amount=created_invoice.amount_total)
|
||||
created_invoice.with_context(tx_currency_id=tx.currency_id.id).pay_and_reconcile(tx.acquirer_id.journal_id, pay_amount=created_invoice.amount_total)
|
||||
if created_invoice.payment_ids:
|
||||
created_invoice.payment_ids[0].payment_transaction_id = tx
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user