From 0879cb88fedb819f91a2ad2cb0044023ef1254d8 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Mon, 9 Apr 2018 19:19:45 +0200 Subject: [PATCH] [FIX] payment: make the error handler works for non s2s acquirer Before this commit, error handling would not work for non s2s payment acquirer since it would always check for `o_payment_add_token_acq_[id]` in the DOM but this is only present for s2s acquirer. Non s2s acquirer got `o_payment_form_acq_[id]` in the DOM. Now, we retrieve the correct DOM element depending if s2s is enabled for this payment acquirer or not. task-1825701 --- addons/payment/static/src/js/payment_form.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/addons/payment/static/src/js/payment_form.js b/addons/payment/static/src/js/payment_form.js index c329aa440cf..9abb0b73424 100644 --- a/addons/payment/static/src/js/payment_form.js +++ b/addons/payment/static/src/js/payment_form.js @@ -177,7 +177,7 @@ odoo.define('payment.payment_form', function (require) { }).fail(function (message, data) { self.displayError( _t('Server Error'), - _t("We are not able to redirect you to the payment form.<") + + _t("We are not able to redirect you to the payment form. ") + data.data.message ); }); @@ -220,7 +220,7 @@ odoo.define('payment.payment_form', function (require) { var form_data = this.getFormData(inputs_form); var ds = $('input[name="data_set"]', acquirer_form)[0]; var wrong_input = false; - + inputs_form.toArray().forEach(function (element) { //skip the check of non visible inputs if ($(element).attr('type') == 'hidden') { @@ -396,7 +396,7 @@ odoo.define('payment.payment_form', function (require) { var acquirer_id = this.getAcquirerIdFromRadio(checked_radio); // if we clicked on an add new payment radio, display its form - if (this.isNewPaymentRadio(checked_radio)) { + if (this.isNewPaymentRadio(checked_radio)) { this.$('#o_payment_add_token_acq_' + acquirer_id).removeClass('hidden'); } else if (this.isFormPaymentRadio(checked_radio)) { @@ -414,8 +414,14 @@ odoo.define('payment.payment_form', function (require) { }, displayError: function (title, message) { var $checkedRadio = this.$('input[type="radio"]:checked'), - acquirerID = this.getAcquirerIdFromRadio($checkedRadio[0]), + acquirerID = this.getAcquirerIdFromRadio($checkedRadio[0]); + var $acquirerForm; + if (this.isNewPaymentRadio($checkedRadio[0])) { $acquirerForm = this.$('#o_payment_add_token_acq_' + acquirerID); + } + else if (this.isFormPaymentRadio($checkedRadio[0])) { + $acquirerForm = this.$('#o_payment_form_acq_' + acquirerID); + } if ($checkedRadio.length === 0) { return new Dialog(null, {