From 0e49ccc4196b5302fbd15d0b11026afb489ce10f Mon Sep 17 00:00:00 2001 From: Toufik Benjaa Date: Wed, 18 Apr 2018 15:58:32 +0200 Subject: [PATCH] [FIX] payment: Save payment token only if user is connected - Fix an issue where the transaction were always set a 'form_save' thus always creating payment tokens. - Fix an issue where when the customer paying while not being logged in was crashing. The issue is due to the fact that we are creating payment transactions linked to no partners, doing so it crashing the code when creating the payment token with no partner set. --- addons/payment/controllers/portal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/payment/controllers/portal.py b/addons/payment/controllers/portal.py index be70f46309e..6f13400356b 100644 --- a/addons/payment/controllers/portal.py +++ b/addons/payment/controllers/portal.py @@ -89,7 +89,7 @@ class WebsitePayment(http.Controller): 'amount': float(amount), 'currency_id': currency_id, 'partner_id': partner_id, - 'type': 'form_save' if acquirer.save_token else 'form', + 'type': 'form_save' if acquirer.save_token != 'none' and partner_id else 'form', } tx = request.env['payment.transaction'].sudo().create(values) @@ -119,7 +119,7 @@ class WebsitePayment(http.Controller): 'currency_id': int(currency_id), 'partner_id': partner_id, 'payment_token_id': pm_id, - 'type': 'form_save' if token.acquirer_id.save_token else 'form', + 'type': 'form_save' if token.acquirer_id.save_token != 'none' and partner_id else 'form', } tx = request.env['payment.transaction'].sudo().create(values)