diff --git a/addons/website_quote/static/src/js/website_quotation.js b/addons/website_quote/static/src/js/website_quotation.js index b694a7e957b..2539dc79365 100644 --- a/addons/website_quote/static/src/js/website_quotation.js +++ b/addons/website_quote/static/src/js/website_quotation.js @@ -63,15 +63,24 @@ if(!$('.o_website_quote').length) { // extract data var self = this; var $confirm_btn = self.$el.find('button[type="submit"]'); + + // Support 2 routes: + // -
+ // - + // The first route is deprecated but might still be used if the template is not updated var href = self.$el.find('form').attr("action"); - var action = href.match(/quote\/([a-z]+)/); - var order_id = href.match(/order_id=(.*)&/); - var token = href.match(/token=(.*)/); - if (token){ - token = token[1]; + if (href) { + var action = href.match(/quote\/([a-z]+)/)[1]; + var order_id = parseInt(href.match(/quote\/[a-z]+\/([0-9]+)/)[1]); + var token = href.match(/token=(.*)/) && href.match(/token=(.*)/)[1]; + } + else { + var action = 'accept'; + var order_id = self.$el.find('form').data("order-id"); + var token = self.$el.find('form').data("token"); } - if (action[1]=='accept') { + if (action == 'accept') { ev.preventDefault(); // process : display errors, or submit var signer_name = self.$("#name").val(); @@ -87,14 +96,14 @@ if(!$('.o_website_quote').length) { } $confirm_btn.prepend(' '); $confirm_btn.attr('disabled', true); - ajax.jsonRpc("/quote/"+action[1], 'call', { - 'order_id': parseInt(order_id[1]), + ajax.jsonRpc("/quote/"+action, 'call', { + 'order_id': order_id, 'token': token, 'signer': signer_name, 'sign': signature?JSON.stringify(signature[1]):false, }).then(function (data) { self.$el.modal('hide'); - window.location.href = '/quote/'+order_id[1]+'/'+token+'?message=3'; + window.location.href = '/quote/'+order_id.toString()+'/'+token+'?message=3'; }); return false; } diff --git a/addons/website_quote/views/website_quotation.xml b/addons/website_quote/views/website_quotation.xml index 37ea63232e3..24538a1dafc 100644 --- a/addons/website_quote/views/website_quotation.xml +++ b/addons/website_quote/views/website_quotation.xml @@ -237,7 +237,7 @@