From 4d5d228b15a0c183d58f3505dbedb9d0e185dacc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 14 Nov 2017 13:23:51 +0100 Subject: [PATCH] [FIX] sale_payment: effectively pay and reconcile invoices when journal is configured Indentation issue leads to pay and reconcile mechanism being called only when no journal was set, which is not the real use case. --- addons/sale_payment/models/payment.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/sale_payment/models/payment.py b/addons/sale_payment/models/payment.py index b36e42a0aac..89979477b39 100644 --- a/addons/sale_payment/models/payment.py +++ b/addons/sale_payment/models/payment.py @@ -88,10 +88,10 @@ class PaymentTransaction(models.Model): self.acquirer_id.provider, self.sale_order_id.name, self.sale_order_id.id) return False self.acquirer_id.journal_id = default_journal - # TDE Note: in post-v11 we could probably add an explicit parameter + update account.payment tx directly at creation, not afterwards - created_invoice.with_context(default_currency_id=self.currency_id.id).pay_and_reconcile(self.acquirer_id.journal_id, pay_amount=created_invoice.amount_total) - if created_invoice.payment_ids: - created_invoice.payment_ids[0].payment_transaction_id = self + # TDE Note: in post-v11 we could probably add an explicit parameter + update account.payment tx directly at creation, not afterwards + created_invoice.with_context(default_currency_id=self.currency_id.id).pay_and_reconcile(self.acquirer_id.journal_id, pay_amount=created_invoice.amount_total) + if created_invoice.payment_ids: + created_invoice.payment_ids[0].payment_transaction_id = self else: _logger.warning('<%s> transaction completed, could not auto-generate invoice for %s (ID %s)', self.acquirer_id.provider, self.sale_order_id.name, self.sale_order_id.id)