[FIX] website_sale_delivery: disable pay button durring update
Steps to reproduce: refer to ticket Bug: if there's no available pickup points on the selected delivery method the pay button is disabled but clicking on a payment option reanbles the button eventhough "_onClickPaymentMethod" doesn't enable the button since _isPayable is false, "_onClickPaymentOption" already enabled the button. Fix: disable the button before updating the payment method also disable the button at the start when changing shipping method (to avoid client clicking pay while carrier data is loading) opw-3432905 closes odoo/odoo#139522 X-original-commit: 6a91e63504cb45d2f80162d2a91b76e733c0facf Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
This commit is contained in:
@@ -34,8 +34,7 @@ publicWidget.registry.websiteSaleDelivery = publicWidget.Widget.extend({
|
||||
if (this.carriers.length > 0) {
|
||||
const carrierChecked = this.carriers.filter(e =>e.checked)
|
||||
if (carrierChecked.length === 0) {
|
||||
const payButton = document.querySelector('button[name="o_payment_submit_button"]');
|
||||
payButton? payButton.disabled = true : null;
|
||||
this._disablePayButton();
|
||||
} else {
|
||||
carrierChecked[0].click();
|
||||
}
|
||||
@@ -193,6 +192,11 @@ publicWidget.registry.websiteSaleDelivery = publicWidget.Widget.extend({
|
||||
}
|
||||
},
|
||||
|
||||
_disablePayButton: function (){
|
||||
var payButton = document.querySelector('button[name="o_payment_submit_button"]');
|
||||
payButton? payButton.disabled = true : null;
|
||||
},
|
||||
|
||||
_disablePayButtonNoPickupPoint : function (ev){
|
||||
const selectedCarrierEl = ev.currentTarget.closest('.o_delivery_carrier_select');
|
||||
const address = selectedCarrierEl.querySelector('.o_order_location_address').innerText
|
||||
@@ -201,8 +205,7 @@ publicWidget.registry.websiteSaleDelivery = publicWidget.Widget.extend({
|
||||
document.querySelectorAll('.error_no_pick_up_point').forEach(el => el.remove());
|
||||
|
||||
if (isPickUp.length > 1 && (address == "" || isPickUp[0].classList.contains("d-none"))) {
|
||||
var payButton = document.querySelector('button[name="o_payment_submit_button"]');
|
||||
payButton? payButton.disabled = true : null;
|
||||
this._disablePayButton();
|
||||
const errorNode = document.createElement("i");
|
||||
errorNode.classList.add("small", "error_no_pick_up_point","ms-2");
|
||||
errorNode.textContent = _t("Select a pick-up point");
|
||||
@@ -224,6 +227,10 @@ publicWidget.registry.websiteSaleDelivery = publicWidget.Widget.extend({
|
||||
|
||||
_onClickPaymentMethod: async function (ev) {
|
||||
const carriers = Array.from(document.querySelectorAll('.o_delivery_carrier_select'))
|
||||
if(carriers.length === 0){
|
||||
return;
|
||||
}
|
||||
this._disablePayButton();
|
||||
let carrierChecked = null;
|
||||
carriers.forEach((carrier) => {
|
||||
if (carrier.querySelector('input').checked){
|
||||
@@ -364,6 +371,7 @@ publicWidget.registry.websiteSaleDelivery = publicWidget.Widget.extend({
|
||||
* @param {Event} ev
|
||||
*/
|
||||
_onCarrierClick: async function (ev) {
|
||||
this._disablePayButton();
|
||||
const radio = ev.currentTarget.closest('.o_delivery_carrier_select').querySelector('input[type="radio"]');
|
||||
if (radio.checked) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user