diff --git a/addons/account_payment/models/payment.py b/addons/account_payment/models/payment.py index 0ad11d39788..389cfa206e1 100644 --- a/addons/account_payment/models/payment.py +++ b/addons/account_payment/models/payment.py @@ -175,3 +175,10 @@ class PaymentTransaction(models.Model): }) return tx + + def _post_process_after_done(self, **kwargs): + # set invoice id in payment transaction when payment being done from sale order + res = super(PaymentTransaction, self)._post_process_after_done() + if kwargs.get('invoice_id'): + self.account_invoice_id = kwargs['invoice_id'] + return res diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py index 343e7ebd116..691de438072 100644 --- a/addons/payment/models/payment_acquirer.py +++ b/addons/payment/models/payment_acquirer.py @@ -684,6 +684,10 @@ class PaymentTransaction(models.Model): return True + @api.multi + def _post_process_after_done(self, **kwargs): + return True + # -------------------------------------------------- # SERVER2SERVER RELATED METHODS # -------------------------------------------------- diff --git a/addons/sale_payment/models/payment.py b/addons/sale_payment/models/payment.py index 857ff857dfb..8076addab09 100644 --- a/addons/sale_payment/models/payment.py +++ b/addons/sale_payment/models/payment.py @@ -103,6 +103,7 @@ class PaymentTransaction(models.Model): 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 + self._post_process_after_done(invoice_id=created_invoice) 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)