diff options
| author | Nicolas Martinelli <nim@odoo.com> | 2015-10-28 13:04:09 +0100 |
|---|---|---|
| committer | Nicolas Martinelli <nim@odoo.com> | 2015-10-28 14:33:07 +0100 |
| commit | de8f3f70fdf810b227554516c76640ee757faa90 (patch) | |
| tree | fba75d1411110287e8476a6eafc5017f240c4d1d /addons/website_quote/static/src/js | |
| parent | dcd8d65fd1c9316f202a34203497ddd937d64244 (diff) | |
[FIX] website_quote: support of 2 routes to accept quote
Complement of commit d9c2d03. We should still support the old route, in
case users do not update the template.
Diffstat (limited to 'addons/website_quote/static/src/js')
| -rw-r--r-- | addons/website_quote/static/src/js/website_quotation.js | 27 |
1 files changed, 18 insertions, 9 deletions
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: + // - <form id="accept" method="POST" t-attf-action="/quote/accept/#{quotation.id}/?token=#{quotation.access_token}" ...> + // - <form id="accept" method="POST" t-att-data-order-id="quotation.id" t-att-data-token="quotation.access_token" ...> + // 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('<i class="fa fa-spinner fa-spin"></i> '); $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; } |
