From c117caae1b4899a3b8dbbdd1a13a8665f3f0f6d6 Mon Sep 17 00:00:00 2001 From: Jorge Pinna Puissant Date: Fri, 15 Feb 2019 07:48:19 +0000 Subject: [PATCH] [FIX] website_sale_delivery: selection when waiting of shipper rendering - Set up as a normal shipper and one which will cause an error (e.g. service not available for customer address; or no price rule matching) - Order a product on eCommerce, go to Payment page When changing of delivery method, from the second delivery, to the first and to the second delivery again, the behavior of the 'Pay Now' button is the follow: * choose second delivery - button disabled * choose first delivery - button enabled * choose second delivery - button disabled If the connection to the server is to slow, the choose of the delivery and the state of the button are not syncronised. That means that at the end of this changing, the button stays active long enough to click it, and pass an order without a delivery charge. Now, only the last request is take into account, and the false positives are avoided. opw-1937575 closes odoo/odoo#31127 --- .../static/src/js/website_sale_delivery.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 79c70becf98..1907df94574 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 @@ -5,6 +5,8 @@ odoo.define('website_sale_delivery.checkout', function (require) { var ajax = require('web.ajax'); var core = require('web.core'); var _t = core._t; + var concurrency = require('web.concurrency'); + var dp = new concurrency.DropPrevious(); /* Handle interactive carrier choice + cart update */ var $pay_button = $('#o_payment_form_pay'); @@ -51,7 +53,7 @@ odoo.define('website_sale_delivery.checkout', function (require) { $pay_button.prop('disabled', true); var carrier_id = $(ev.currentTarget).val(); var values = {'carrier_id': carrier_id}; - ajax.jsonRpc('/shop/update_carrier', 'call', values) + dp.add(ajax.jsonRpc('/shop/update_carrier', 'call', values)) .then(_onCarrierUpdateAnswer); };