[IMP] payment, sale_payment: set invoice id in payment transaction form after payment being done from sale order.

Until now invoice_id is filled on the transaction only when we make
payments through invoice. However if we make payments through sale order
then invoice_id is not filled.

This commit fixes that issue. As there is no common point between
sale_payment and account_payment except payment, a void method is added
in payment and an override done in account_payment. That was when both
modules are installed code is correctly triggered.

This commit is related to task ID 1813602. Closes #22746 .
This commit is contained in:
Nikunj Ladava
2018-03-20 16:16:27 +01:00
committed by Thibault Delavallée
parent b6e0f1ad59
commit cbd395ec36
3 changed files with 12 additions and 0 deletions
+7
View File
@@ -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
@@ -684,6 +684,10 @@ class PaymentTransaction(models.Model):
return True
@api.multi
def _post_process_after_done(self, **kwargs):
return True
# --------------------------------------------------
# SERVER2SERVER RELATED METHODS
# --------------------------------------------------
+1
View File
@@ -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)