From 8533c19a6020461081c952c74bd6e043d26c79c7 Mon Sep 17 00:00:00 2001 From: Nans Lefebvre Date: Tue, 16 Jul 2019 14:15:27 +0000 Subject: [PATCH] [FIX] payment_authorize: save payment token from form validated transaction https://docs.python.org/3/library/stdtypes.html#truth By default, an object is considered true unless its class defines either a __bool__() method that returns False or a __len__() method that returns zero Since etree elements are iterator, they define a len function. However it turns out that customerProfileId has always no children. So bool(find(x)) is always False; the intended meaning was find(x) is None. opw 1999427 closes odoo/odoo#34922 Signed-off-by: Nans Lefebvre (len) --- addons/payment_authorize/models/authorize_request.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/payment_authorize/models/authorize_request.py b/addons/payment_authorize/models/authorize_request.py index 922d9df1bf1..e3e65648ee0 100644 --- a/addons/payment_authorize/models/authorize_request.py +++ b/addons/payment_authorize/models/authorize_request.py @@ -226,7 +226,7 @@ class AuthorizeAPI(): etree.SubElement(customer, "email").text = partner.email or '' response = self._authorize_request(root) res = dict() - if not response.find('customerProfileId'): + if response.find('customerProfileId') is None: # Warning: do not use bool(etree) as the semantics is very misleading _logger.warning( 'Unable to create customer payment profile, data missing from transaction. Transaction_id: %s - Partner_id: %s' % (transaction_id, partner)