From c60436c82adcc2fa505804b2481adacdee1fd1ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 29 Dec 2025 12:36:26 +0100 Subject: [PATCH] Split the UBL OrderReference field into sale reference and sale number Closes #14452 --- modules/edocument_ubl/edocument.py | 10 ++++++++++ modules/edocument_ubl/setup.py | 1 + modules/edocument_ubl/template/2/CreditNote.xml | 3 ++- modules/edocument_ubl/template/2/Invoice.xml | 3 ++- modules/edocument_ubl/tests/test_module.py | 3 ++- modules/edocument_ubl/tryton.cfg | 1 + 6 files changed, 18 insertions(+), 3 deletions(-) diff --git a/modules/edocument_ubl/edocument.py b/modules/edocument_ubl/edocument.py index b0d48892de..4c7e603003 100644 --- a/modules/edocument_ubl/edocument.py +++ b/modules/edocument_ubl/edocument.py @@ -169,6 +169,16 @@ class Invoice(Model): else: return self.invoice.tax_identifier + @cached_property + def sale_reference(self): + if hasattr(self.invoice, 'sales'): + return ','.join(s.reference for s in self.invoice.sales) + + @cached_property + def sale_number(self): + if hasattr(self.invoice, 'sales'): + return ','.join(s.number for s in self.invoice.sales) + @property def taxes(self): def key(line): diff --git a/modules/edocument_ubl/setup.py b/modules/edocument_ubl/setup.py index b40eafd972..230692ae75 100755 --- a/modules/edocument_ubl/setup.py +++ b/modules/edocument_ubl/setup.py @@ -56,6 +56,7 @@ tests_require = [ get_require_version('trytond_account_invoice'), get_require_version('trytond_document_incoming_invoice'), get_require_version('trytond_purchase'), + get_require_version('trytond_sale'), ] setup(name=name, diff --git a/modules/edocument_ubl/template/2/CreditNote.xml b/modules/edocument_ubl/template/2/CreditNote.xml index 5389b74a9d..6e34959db3 100644 --- a/modules/edocument_ubl/template/2/CreditNote.xml +++ b/modules/edocument_ubl/template/2/CreditNote.xml @@ -21,7 +21,8 @@ this repository contains the full copyright notices and license terms. --> ${this.invoice.currency.code} ${this.invoice.reference} - ${this.invoice.origins or this.invoice.number} + ${this.sale_reference or 'NA'} + ${this.sale_number} ${document['id']} diff --git a/modules/edocument_ubl/template/2/Invoice.xml b/modules/edocument_ubl/template/2/Invoice.xml index 5d2b613215..50755aa179 100644 --- a/modules/edocument_ubl/template/2/Invoice.xml +++ b/modules/edocument_ubl/template/2/Invoice.xml @@ -21,7 +21,8 @@ this repository contains the full copyright notices and license terms. --> ${this.invoice.currency.code} ${this.invoice.reference} - ${this.invoice.origins or this.invoice.number} + ${this.sale_reference or 'NA'} + ${this.sale_number} ${document['id']} diff --git a/modules/edocument_ubl/tests/test_module.py b/modules/edocument_ubl/tests/test_module.py index 2adab8ee32..7b3ebc40d2 100644 --- a/modules/edocument_ubl/tests/test_module.py +++ b/modules/edocument_ubl/tests/test_module.py @@ -135,7 +135,8 @@ def get_invoice(): class EdocumentUblTestCase(ModuleTestCase): "Test Edocument Ubl module" module = 'edocument_ubl' - extras = ['account_invoice', 'document_incoming_invoice', 'purchase'] + extras = [ + 'account_invoice', 'document_incoming_invoice', 'purchase', 'sale'] @with_transaction() def test_Invoice_2(self): diff --git a/modules/edocument_ubl/tryton.cfg b/modules/edocument_ubl/tryton.cfg index 051f728e15..0dd889085e 100644 --- a/modules/edocument_ubl/tryton.cfg +++ b/modules/edocument_ubl/tryton.cfg @@ -9,6 +9,7 @@ extras_depend: account_invoice document_incoming_invoice purchase + sale xml: account.xml message.xml