From d38bb3fea5e7acc7654f3990ebe03ff291d7ef95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 11 Aug 2026 12:02:09 +0200 Subject: [PATCH] Test findtext result as boolean when parsing UBL invoice Closes #15003 (grafted from ebb739d278526b86ec2f4ac31df63388874c2487) --HG-- branch : 8.0 --- modules/edocument_ubl/edocument.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/edocument_ubl/edocument.py b/modules/edocument_ubl/edocument.py index 51dfe67da6..cb5fbe98eb 100644 --- a/modules/edocument_ubl/edocument.py +++ b/modules/edocument_ubl/edocument.py @@ -1080,9 +1080,8 @@ class Invoice(Model): address.building_number = address_el.findtext('./{*}BuildingNumber') address.city = address_el.findtext('./{*}CityName') address.postal_code = address_el.findtext('./{*}PostalZone') - if (country_code := address_el.findtext( - './{*}Country/{*}IdentificationCode[@listId="ISO3166-1"]') - ) is not None: + if country_code := address_el.findtext( + './{*}Country/{*}IdentificationCode[@listId="ISO3166-1"]'): try: country, = Country.search([ ('code', '=', country_code), @@ -1221,8 +1220,7 @@ class Invoice(Model): pass else: return product - if (code := item.findtext('./{*}BuyersItemIdentification/{*}ID') - ) is not None: + if code := item.findtext('./{*}BuyersItemIdentification/{*}ID'): try: product, = Product.search([ ('code', '=', code),