From 0b412c250afc60131188ce248087dae2c2a53574 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 17 May 2018 13:52:06 +0200 Subject: [PATCH] [FIX] website_sale_delivery: selection at first rendering - Set up as a shipper with the highest priority one which will cause an error (e.g. service not available for customer address) - Order a product on eCommerce, go to Payment page Nothing prevents to click on the 'Pay Now' button, although the shipper rating has failed. Moreover, the error is not displayed in the label of the shipper. Workaround: we force a click on the selected default shipper to trigger the update. The good solution would probably be to have a completely dynamic shipper rating integration, instead of some processing at first rendering and then extra dynamic processing. opw-1838765 --- addons/website_sale/static/src/js/website_sale_tour_buy.js | 2 +- .../static/src/js/website_sale_delivery.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/website_sale/static/src/js/website_sale_tour_buy.js b/addons/website_sale/static/src/js/website_sale_tour_buy.js index 3c9144b02c2..b1f045a037c 100644 --- a/addons/website_sale/static/src/js/website_sale_tour_buy.js +++ b/addons/website_sale/static/src/js/website_sale_tour_buy.js @@ -77,7 +77,7 @@ tour.register('shop_buy_product', { content: "Pay Now", //Either there are multiple payment methods, and one is checked, either there is only one, and therefore there are no radio inputs extra_trigger: '#payment_method label:contains("Wire Transfer") input:checked,#payment_method:not(:has("input:radio:visible"))', - trigger: 'button[id="o_payment_form_pay"]:visible', + trigger: 'button[id="o_payment_form_pay"]:visible:not(:disabled)', }, { content: "finish", diff --git a/addons/website_sale_delivery/static/src/js/website_sale_delivery.js b/addons/website_sale_delivery/static/src/js/website_sale_delivery.js index 5e3957a6b95..971e604d1d1 100644 --- a/addons/website_sale_delivery/static/src/js/website_sale_delivery.js +++ b/addons/website_sale_delivery/static/src/js/website_sale_delivery.js @@ -44,6 +44,12 @@ odoo.define('website_sale_delivery.checkout', function (require) { var $carriers = $("#delivery_carrier input[name='delivery_type']"); $carriers.click(_onCarrierClick); + // Workaround to: + // - update the amount/error on the label at first rendering + // - prevent clicking on 'Pay Now' if the shipper rating fails + if ($carriers.length > 0) { + $carriers.filter(':checked').click(); + } /* Handle stuff */ $(".oe_website_sale select[name='shipping_id']").on('change', function () {