details: https://code.tryton.org/tryton/commit/a479209485e6
branch: 7.8
user: Cédric Krier <[email protected]>
date: Mon Jan 19 11:48:55 2026 +0100
description:
Use the company IDs from UBL as identifier
Closes #14515
(grafted from bf1e38173774e56269d43ca484fcff18a3e58c6f)
diffstat:
modules/edocument_ubl/edocument.py | 42 +++++++++++++++++++++----------------
1 files changed, 24 insertions(+), 18 deletions(-)
diffs (75 lines):
diff -r a169586eb1ad -r a479209485e6 modules/edocument_ubl/edocument.py
--- a/modules/edocument_ubl/edocument.py Fri Jan 23 12:12:27 2026 +0100
+++ b/modules/edocument_ubl/edocument.py Mon Jan 19 11:48:55 2026 +0100
@@ -630,7 +630,11 @@
pool = Pool()
Party = pool.get('party.party')
- for identifier in party_el.iterfind('./{*}PartyIdentification/{*}ID'):
+ for identifier in chain(
+ party_el.iterfind('./{*}PartyIdentification/{*}ID'),
+ party_el.iterfind('./{*}PartyLegalEntity/{*}CompanyID'),
+ party_el.iterfind('./{*}PartyTaxScheme/{*}CompanyID'),
+ ):
if identifier.text:
parties = Party.search([
('identifiers.code', '=', identifier.text),
@@ -646,10 +650,18 @@
party = Party()
party.name = party_el.findtext('./{*}PartyName/{*}Name')
identifiers = []
- for identifier in party_el.iterfind('./{*}PartyIdentification/{*}ID'):
+ identifiers_done = set()
+ for identifier in chain(
+ party_el.iterfind('./{*}PartyIdentification/{*}ID'),
+ party_el.iterfind('./{*}PartyTaxScheme/{*}CompanyID'),
+ party_el.iterfind('./{*}PartyLegalEntity/{*}CompanyID'),
+ ):
if identifier.text:
- identifiers.append(cls._create_2_party_identifier(
- identifier))
+ identifier_key = (identifier.text, identifier.get('schemeID'))
+ if identifier_key not in identifiers_done:
+ identifiers.append(cls._create_2_party_identifier(
+ identifier))
+ identifiers_done.add(identifier_key)
party.identifiers = identifiers
if (address := party_el.find('./{*}PostalAddress')
) is not None:
@@ -770,8 +782,12 @@
pass
else:
return customer_code.company
- for identifier in customer_party.iterfind(
- './{*}Party/{*}PartyIdentification/{*}ID'):
+ party_el = customer_party.find('./{*}Party')
+ for identifier in chain(
+ party_el.iterfind('./{*}PartyIdentification/{*}ID'),
+ party_el.iterfind('./{*}PartyTaxScheme/{*}CompanyID'),
+ party_el.iterfind('./{*}PartyLegalEntity/{*}CompanyID'),
+ ):
if identifier.text:
companies = Company.search([
('party.identifiers.code', '=', identifier.text),
@@ -780,19 +796,9 @@
company, = companies
return company
- for company_id in customer_party.iterfind(
- './{*}Party/{*}PartyTaxScheme/{*}CompanyID'):
- companies = Company.search([
- ('party.identifiers.code', '=', company_id.text),
- ])
- if len(companies) == 1:
- company, = companies
- return company
-
for name in chain(
- customer_party.iterfind(
- './{*}Party/{*}PartyTaxScheme/{*}RegistrationName'),
- customer_party.iterfind('./{*}Party/{*}PartyName/{*}Name'),
+ party_el.iterfind('./{*}PartyTaxScheme/{*}RegistrationName'),
+ party_el.iterfind('./{*}PartyName/{*}Name'),
):
if name is None:
continue