Use schemeID to search for identifier of the same type

Closes #14516
This commit is contained in:
Cédric Krier
2026-01-19 11:43:28 +01:00
parent 90ef7c822c
commit 8ae58308ce
+14 -2
View File
@@ -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