[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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@
|
||||
<!-- modal relative to the actions Accept/Reject/Cancel -->
|
||||
<div class="modal fade" id="modalaccept" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog" t-if="not quotation.require_payment and not need_payment">
|
||||
<form id="accept" method="POST" t-attf-action="/quote/accept?order_id=#{quotation.id}&token=#{quotation.access_token}" class="js_accept_json modal-content js_website_submit_form">
|
||||
<form id="accept" method="POST" t-att-data-order-id="quotation.id" t-att-data-token="quotation.access_token" class="js_accept_json modal-content js_website_submit_form">
|
||||
<input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
|
||||
|
||||
Reference in New Issue
Block a user