From d36dca2d2de8bf51dc9b48d22ab41ab3f52aa82a Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Tue, 27 Dec 2016 14:01:40 +0100 Subject: [PATCH] [FIX] website_sale: 2 state tags and same shipping change If website_sale_delivery is installed, when we choose same invoice address as shipping or another one, a new set of country/state are displayed. It is done since if we are using the invoicing address as shipping, the address must be in the allowed shipping countries and states. This was solved for some instances with 164b8ed01a96 but failed in other instances. With this fix the two state select tags have references to their own options which allow us to have it alright for the several possibilities. opw-693127 --- addons/website_sale/static/src/js/website_sale.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/website_sale/static/src/js/website_sale.js b/addons/website_sale/static/src/js/website_sale.js index 6114d5e0107..094185c91da 100644 --- a/addons/website_sale/static/src/js/website_sale.js +++ b/addons/website_sale/static/src/js/website_sale.js @@ -347,9 +347,12 @@ $('.oe_website_sale').each(function () { $('input.js_variant_change, select.js_variant_change', this).first().trigger('change'); }); - var state_options = $("select[name='state_id']:visible option:not(:first)"); + $("select[name='state_id']").each(function(){ + $(this).data('options', $(this).find('option:not(:first)')); + }); $(oe_website_sale).on('change', "select[name='country_id']", function () { - var select = $("select[name='state_id']:visible"); + var select = $("select[name='state_id']:enabled"); + var state_options = select.data('options'); var selected_state = select.val(); state_options.detach(); var displayed_state = state_options.filter("[data-country_id="+($(this).val() || 0)+"]");