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