[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) <vchu@odoo.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user