diff --git a/addons/website_sale_picking/static/src/js/payment_form.js b/addons/website_sale_picking/static/src/js/payment_form.js index b8213bac524..c2a5e680007 100644 --- a/addons/website_sale_picking/static/src/js/payment_form.js +++ b/addons/website_sale_picking/static/src/js/payment_form.js @@ -65,8 +65,13 @@ publicWidget.registry.websiteSaleDelivery.include({ const input = ev.currentTarget.querySelector('input'); let atLeastOneOptionAvailable = false; + // Jquery because the button does not behave nicely with vanilla dataset. + let $payButton = $('button[name="o_payment_submit_button"]'); for (let option of this.paymentOptions) { if (option.dataset.isOnsite && input.dataset.deliveryType !== 'onsite') { + if (option.checked) { // The payment option was selected. + $payButton.attr('disabled', true); // Reset the submit button. + } this._setEnablePaymentOption(option, false); } else{ if(option.dataset.isOnsite){ @@ -76,16 +81,12 @@ publicWidget.registry.websiteSaleDelivery.include({ } } - // Jquery because the button does not behave nicely with vanilla dataset. - let $payButton = $('button[name="o_payment_submit_button"]'); let disabledReasons = $payButton.data('disabled_reasons') || {}; disabledReasons.noOptionAvailableOnsite = false; if (!atLeastOneOptionAvailable) { this.warning.classList.remove('d-none'); disabledReasons.noOptionAvailableOnsite = true; - } else if (this.paymentOptions.length === 1) { - $(this.paymentOptions[0]).click(); // Make sure the option is selected if that's the only one, because the input is hidden in that case. } $payButton.data('disabled_reasons', disabledReasons); }