From 3c305daded374d22a40e22bcdf6bf4c9e4cb3359 Mon Sep 17 00:00:00 2001 From: Toufik Ben Jaa Date: Fri, 17 May 2019 09:55:59 +0000 Subject: [PATCH] [FIX] payment: do not display postgres operational errors - When processing payments on the payments processing page, `psycopg2.OperationalError` can be raised. We do not want those exceptions to be displayed to the customers, instead we want the polling page to try to process the payments again. This commit hides the display of psycopg2 operational errors. - This commit also fixes the "processing your payments" message being hidden after the first polling, no matter if the processing has succeeded or not. closes odoo/odoo#33462 Signed-off-by: Toufik Benjaa (tbe) --- addons/payment/controllers/portal.py | 5 +++++ addons/payment/static/src/js/payment_processing.js | 9 ++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/addons/payment/controllers/portal.py b/addons/payment/controllers/portal.py index 55a4d08e4b9..c6b1fc41b41 100644 --- a/addons/payment/controllers/portal.py +++ b/addons/payment/controllers/portal.py @@ -2,6 +2,7 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. import logging +import psycopg2 from odoo import http, _ from odoo.http import request @@ -93,6 +94,10 @@ class PaymentProcessing(http.Controller): tx_to_process = payment_transaction_ids.filtered(lambda x: x.state == 'done' and x.is_processed is False) try: tx_to_process._post_process_after_done() + except psycopg2.OperationalError as e: + request.env.cr.rollback() + result['success'] = False + result['error'] = "tx_process_retry" except Exception as e: request.env.cr.rollback() result['success'] = False diff --git a/addons/payment/static/src/js/payment_processing.js b/addons/payment/static/src/js/payment_processing.js index 4397bf134f1..5409b915526 100644 --- a/addons/payment/static/src/js/payment_processing.js +++ b/addons/payment/static/src/js/payment_processing.js @@ -54,6 +54,8 @@ odoo.define('payment.processing', function (require) { } else { switch(data.error) { + case "tx_process_retry": + break; case "no_tx_found": self.displayContent("payment.no_tx_found", {}); break; @@ -63,11 +65,7 @@ odoo.define('payment.processing', function (require) { } } self.startPolling(); - }).always(function(){ - if ($.blockUI) { - $.unblockUI(); - } - }).fail(function(e) { + }).fail(function(e) { self.displayContent("payment.rpc_error", {}); self.startPolling(); }); @@ -117,6 +115,7 @@ odoo.define('payment.processing', function (require) { }, displayContent: function (xmlid, render_values) { var html = Qweb.render(xmlid, render_values); + $.unblockUI(); this.$el.find('.o_payment_processing_content').html(html); }, displayLoading: function () {