From 2d3e9d21a7b5c05960b44df9685313a6525cbd43 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 29 Sep 2015 12:10:04 +0200 Subject: [PATCH] [FIX] website_sale: ensure payment transaction is for current order When ordering on the ecommerce, if a payment transaction was found in the session, this transaction was used as transaction for the current order. Nevertheless, if the transction is no longer linked to the current order, we should not use it. This happened, for example, when the quotation was deleted while the customer/user didn't close its browser, and the transaction id was therefore still in its session. opw-650417 --- addons/website_sale/controllers/main.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index a7c9b68d342..1e9d9d52f37 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -731,13 +731,16 @@ class website_sale(http.Controller): # find an already existing transaction tx = request.website.sale_get_transaction() if tx: - if tx.state == 'draft': # button cliked but no more info -> rewrite on tx or create a new one ? + tx_id = tx.id + if tx.reference != order.name: + tx = False + tx_id = False + elif tx.state == 'draft': # button cliked but no more info -> rewrite on tx or create a new one ? tx.write({ 'acquirer_id': acquirer_id, 'amount': order.amount_total, }) - tx_id = tx.id - else: + if not tx: tx_id = transaction_obj.create(cr, SUPERUSER_ID, { 'acquirer_id': acquirer_id, 'type': 'form',