From aebe30a91baeefa22cb188ed50ba829fd92926b1 Mon Sep 17 00:00:00 2001 From: "Valeriya(vchu)" Date: Tue, 17 Oct 2023 13:41:41 +0000 Subject: [PATCH] [FIX] website_sale_picking, payment: always show payment options radio After commit 0b69bf02 the following bug appeared. Steps to reproduce: 1) activate only 'on site pick' shipping method 2) activate only 'pay on site' payment provider 3) add product of type 'product' to the cart and proceed to /shop/payment 4) observe the traceback This bug happens in website_sale_picking checkout_form.js when payment option is clicked on not yet initialized payment form widget. With this commit we always show payment options radio even if there is only one available, which allows to remove the problematic code in website_sale_picking. opw-3475563 opw-3451097 closes odoo/odoo#139130 X-original-commit: 2b6ef409dc2187905812b1a8f6491210699ba76d Related: odoo/enterprise#49147 Signed-off-by: Valeriya Chuprina (vchu) --- .../website_sale_picking/static/src/js/payment_form.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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); }