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