diff --git a/addons/l10n_dk_oioubl/__manifest__.py b/addons/l10n_dk_oioubl/__manifest__.py
index 79dd4593596..4126c8546fe 100644
--- a/addons/l10n_dk_oioubl/__manifest__.py
+++ b/addons/l10n_dk_oioubl/__manifest__.py
@@ -12,6 +12,9 @@ E-invoice implementation for the Denmark
'account_edi_ubl_cii',
'l10n_dk',
],
+ 'data': [
+ 'data/oioubl_templates.xml',
+ ],
'installable': True,
'auto_install': True,
'license': 'LGPL-3',
diff --git a/addons/l10n_dk_oioubl/data/oioubl_templates.xml b/addons/l10n_dk_oioubl/data/oioubl_templates.xml
new file mode 100644
index 00000000000..0eb83e3615b
--- /dev/null
+++ b/addons/l10n_dk_oioubl/data/oioubl_templates.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/l10n_dk_oioubl/models/account_edi_xml_oioubl_201.py b/addons/l10n_dk_oioubl/models/account_edi_xml_oioubl_201.py
index 2dfc801fdf7..5f72508b57e 100644
--- a/addons/l10n_dk_oioubl/models/account_edi_xml_oioubl_201.py
+++ b/addons/l10n_dk_oioubl/models/account_edi_xml_oioubl_201.py
@@ -1,4 +1,5 @@
from odoo import _, models, tools
+from odoo.tools import html2plaintext
DANISH_NATIONAL_IT_AND_TELECOM_AGENCY_ID = '320'
@@ -61,9 +62,9 @@ class AccountEdiXmlOIOUBL201(models.AbstractModel):
def _export_invoice_vals(self, invoice):
# EXTENDS account.edi.xml.ubl_20
vals = super()._export_invoice_vals(invoice)
+ vals['PaymentTermsType_template'] = 'l10n_dk_oioubl.oioubl_PaymentTermsType'
vals['vals'].update({
'customization_id': 'OIOUBL-2.01',
- 'AddressType_template': 'l10n_dk_oioubl.oioubl_201_AddressType',
# ProfileID is the property that define which documents the company can send and receive
# 'Procurement-BilSim-1.0' is the simplest one: invoice and bill
# https://www.oioubl.info/documents/en/en/Guidelines/OIOUBL_GUIDE_PROFILES.pdf
@@ -211,9 +212,25 @@ class AccountEdiXmlOIOUBL201(models.AbstractModel):
return vals
def _get_invoice_payment_terms_vals_list(self, invoice):
- # cleaned atm because it's not mandatory and the standard payment terms gets the document rejected for validation
- # https://www.oioubl.info/Classes/en/PaymentTerms.html
- return []
+ # OVERRIDES 'account_edi_ubl_cii'
+ if not invoice.invoice_payment_term_id:
+ return []
+
+ sign = 1 if invoice.is_inbound(include_receipts=True) else -1
+ return [
+ {
+ 'id': line.id,
+ 'amount': sign * line.amount_currency,
+ 'currency_name': line.currency_id.name,
+ 'currency_dp': self._get_currency_decimal_places(line.currency_id),
+ 'note_vals': [{'note_vals': [{'note': html2plaintext(invoice.invoice_payment_term_id.note)}]}],
+ 'settlement_period': {
+ 'start_date': invoice.invoice_date,
+ 'end_date': line.date_maturity,
+ }
+ }
+ for line in invoice.line_ids.filtered(lambda line: line.display_type == 'payment_term').sorted('date_maturity')
+ ]
def _get_tax_category_list(self, invoice, taxes):
# EXTENDS account.edi.common
diff --git a/addons/l10n_dk_oioubl/tests/test_files/from_odoo/oioubl_out_invoice_foreign_partner_be.xml b/addons/l10n_dk_oioubl/tests/test_files/from_odoo/oioubl_out_invoice_foreign_partner_be.xml
index 35e05af9d15..e80243cfb91 100644
--- a/addons/l10n_dk_oioubl/tests/test_files/from_odoo/oioubl_out_invoice_foreign_partner_be.xml
+++ b/addons/l10n_dk_oioubl/tests/test_files/from_odoo/oioubl_out_invoice_foreign_partner_be.xml
@@ -168,6 +168,22 @@
DK5000400440116243
+
+ ___ignore___
+ 450.00
+
+ 2017-01-01
+ 2017-01-01
+
+
+
+ ___ignore___
+ 1050.00
+
+ 2017-01-01
+ 2017-02-28
+
+
0.00
diff --git a/addons/l10n_dk_oioubl/tests/test_files/from_odoo/oioubl_out_invoice_foreign_partner_fr.xml b/addons/l10n_dk_oioubl/tests/test_files/from_odoo/oioubl_out_invoice_foreign_partner_fr.xml
index de9b88af9df..4be2175873a 100644
--- a/addons/l10n_dk_oioubl/tests/test_files/from_odoo/oioubl_out_invoice_foreign_partner_fr.xml
+++ b/addons/l10n_dk_oioubl/tests/test_files/from_odoo/oioubl_out_invoice_foreign_partner_fr.xml
@@ -167,6 +167,22 @@
DK5000400440116243
+
+ ___ignore___
+ 450.00
+
+ 2017-01-01
+ 2017-01-01
+
+
+
+ ___ignore___
+ 1050.00
+
+ 2017-01-01
+ 2017-02-28
+
+
0.00
diff --git a/addons/l10n_dk_oioubl/tests/test_files/from_odoo/oioubl_out_invoice_partner_dk.xml b/addons/l10n_dk_oioubl/tests/test_files/from_odoo/oioubl_out_invoice_partner_dk.xml
index 8c4c4c9a5e1..f95976be2cd 100644
--- a/addons/l10n_dk_oioubl/tests/test_files/from_odoo/oioubl_out_invoice_partner_dk.xml
+++ b/addons/l10n_dk_oioubl/tests/test_files/from_odoo/oioubl_out_invoice_partner_dk.xml
@@ -168,6 +168,22 @@
DK5000400440116243
+
+ ___ignore___
+ 562.50
+
+ 2017-01-01
+ 2017-01-01
+
+
+
+ ___ignore___
+ 1312.50
+
+ 2017-01-01
+ 2017-02-28
+
+
375.00