From 8ae58308cef54b14b95b1eb9091779fd4cb81729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 19 Jan 2026 11:43:28 +0100 Subject: [PATCH] Use schemeID to search for identifier of the same type Closes #14516 --- modules/edocument_ubl/edocument.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/edocument_ubl/edocument.py b/modules/edocument_ubl/edocument.py index f5de9837be..a5c073b8d1 100644 --- a/modules/edocument_ubl/edocument.py +++ b/modules/edocument_ubl/edocument.py @@ -636,8 +636,14 @@ class Invoice(Model): party_el.iterfind('./{*}PartyTaxScheme/{*}CompanyID'), ): if identifier.text: + domain = [ + ('code', '=', identifier.text), + ] + if schemeId := identifier.get('schemeID'): + if type := ISO6523.get(schemeId): + domain.append(('type', '=', type)) parties = Party.search([ - ('identifiers.code', '=', identifier.text), + ('identifiers', 'where', domain), ]) if len(parties) == 1: party, = parties @@ -791,8 +797,14 @@ class Invoice(Model): party_el.iterfind('./{*}PartyLegalEntity/{*}CompanyID'), ): if identifier.text: + domain = [ + ('code', '=', identifier.text), + ] + if schemeId := identifier.get('schemeID'): + if type := ISO6523.get(schemeId): + domain.append(('type', '=', type)) companies = Company.search([ - ('party.identifiers.code', '=', identifier.text), + ('party.identifiers', 'where', domain), ]) if len(companies) == 1: company, = companies