[FIX] payment_stripe, website_quote, website_sale: update SO
A side effect of commit b9d1239eff if that the method `sale_get_order`,
which is used to retrieve the SO, will also update information on this
SO (change partner, change pricelist...). We therefore need another way
to retrieve the SO.
opw-692919
This commit is contained in:
@@ -47,8 +47,14 @@ odoo.define('payment_stripe.stripe', function(require) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var so_token = $("input[name='token']").val();
|
||||||
|
var so_id = $("input[name='return_url']").val().match(/quote\/([0-9]+)/);
|
||||||
|
if (so_id) {
|
||||||
|
so_id = parseInt(so_id[1]);
|
||||||
|
}
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
ajax.jsonRpc('/shop/payment/transaction/' + acquirer_id, 'call', {}).then(function (data) {
|
ajax.jsonRpc('/shop/payment/transaction/' + acquirer_id, 'call', {'so_id': so_id, 'so_token': so_token}).then(function (data) {
|
||||||
$form.html(data);
|
$form.html(data);
|
||||||
handler.open({
|
handler.open({
|
||||||
name: $("input[name='merchant']").val(),
|
name: $("input[name='merchant']").val(),
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ class sale_quote(http.Controller):
|
|||||||
|
|
||||||
if not Order:
|
if not Order:
|
||||||
return request.render('website.404')
|
return request.render('website.404')
|
||||||
request.session['sale_order_id'] = Order.id
|
|
||||||
|
|
||||||
days = 0
|
days = 0
|
||||||
if Order.validity_date:
|
if Order.validity_date:
|
||||||
|
|||||||
@@ -771,7 +771,7 @@ class WebsiteSale(http.Controller):
|
|||||||
return request.redirect("/shop/payment?error=no_token_or_missmatch_tx")
|
return request.redirect("/shop/payment?error=no_token_or_missmatch_tx")
|
||||||
|
|
||||||
@http.route(['/shop/payment/transaction/<int:acquirer_id>'], type='json', auth="public", website=True)
|
@http.route(['/shop/payment/transaction/<int:acquirer_id>'], type='json', auth="public", website=True)
|
||||||
def payment_transaction(self, acquirer_id, tx_type='form', token=None):
|
def payment_transaction(self, acquirer_id, tx_type='form', token=None, **kwargs):
|
||||||
""" Json method that creates a payment.transaction, used to create a
|
""" Json method that creates a payment.transaction, used to create a
|
||||||
transaction when the user clicks on 'pay now' button. After having
|
transaction when the user clicks on 'pay now' button. After having
|
||||||
created the transaction, the event continues and the user is redirected
|
created the transaction, the event continues and the user is redirected
|
||||||
@@ -781,7 +781,16 @@ class WebsiteSale(http.Controller):
|
|||||||
user is redirected to the checkout page
|
user is redirected to the checkout page
|
||||||
"""
|
"""
|
||||||
Transaction = request.env['payment.transaction'].sudo()
|
Transaction = request.env['payment.transaction'].sudo()
|
||||||
order = request.website.sale_get_order()
|
|
||||||
|
# In case the route is called directly from the JS (as done in Stripe payment method)
|
||||||
|
so_id = kwargs.get('so_id')
|
||||||
|
so_token = kwargs.get('so_token')
|
||||||
|
if so_id and so_token:
|
||||||
|
order = request.env['sale.order'].sudo().search([('id', '=', so_id), ('access_token', '=', so_token)])
|
||||||
|
elif so_id:
|
||||||
|
order = request.env['sale.order'].search([('id', '=', so_id)])
|
||||||
|
else:
|
||||||
|
order = request.website.sale_get_order()
|
||||||
if not order or not order.order_line or acquirer_id is None:
|
if not order or not order.order_line or acquirer_id is None:
|
||||||
return request.redirect("/shop/checkout")
|
return request.redirect("/shop/checkout")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user