From 4ef4aa2083af213c3dec807d1c386c571ad02dd9 Mon Sep 17 00:00:00 2001 From: Barad Mahendra Date: Tue, 4 Dec 2018 11:54:36 +0000 Subject: [PATCH] [IMP] payment: Log error message on payment transaction failure Currently when the payment is initiated there is a message in sale order for waiting for confirmation. But when the payment returns an error there is no message on sales order so it's not clear for the end user that payment is still pending. Related Task ID : 58741 --- addons/payment/models/payment_acquirer.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/payment/models/payment_acquirer.py b/addons/payment/models/payment_acquirer.py index f8c02505985..fc7a69e4784 100644 --- a/addons/payment/models/payment_acquirer.py +++ b/addons/payment/models/payment_acquirer.py @@ -673,6 +673,9 @@ class PaymentTransaction(models.Model): elif self.state == 'cancel' and self.state_message: message = _('The transaction %s with %s for %s has been cancelled with the following message: %s') message_vals.append(self.state_message) + elif self.state == 'error' and self.state_message: + message = _('The transaction %s with %s for %s has return failed with the following error message: %s') + message_vals.append(self.state_message) else: message = _('The transaction %s with %s for %s has been cancelled.') return message % tuple(message_vals) @@ -771,6 +774,7 @@ class PaymentTransaction(models.Model): 'date': datetime.now().strftime(DEFAULT_SERVER_DATETIME_FORMAT), 'state_message': msg, }) + self._log_payment_transaction_received() @api.multi def _post_process_after_done(self):