From aa2d54d0017881812221af4a580ebef46b47f460 Mon Sep 17 00:00:00 2001 From: "Claire Bretton (clbr)" Date: Thu, 18 Apr 2024 12:00:26 +0200 Subject: [PATCH] [FIX] account_edi_ubl_cii,l10n_account_edi_ubl_cii_tests: fix facturx mass download Context: in 17.0 we enabled mass download for invoices. We expect this download to create a zip with all PDF invoices and their related xml files. Steps to reproduce: 1. Install l10n_fr 2. Create two invoices to french partners 3. Send & Print the two invoices and select 'Factur-x" and "Download" 4. A .zip file is generated with two PDF but only **one** XML file "factur-x.xml" Cause: The name of the XML file for the factur-x XML file is not specific to related invoice, it gets overriden each time it is generated. closes odoo/odoo#162406 See: https://github.com/odoo/odoo/pull/137382 Signed-off-by: Laurent Smet (las) --- .../models/account_edi_xml_cii_facturx.py | 2 +- .../tests/test_xml_cii_fr.py | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py b/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py index f168fec8d0b..95f04deb12a 100644 --- a/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py +++ b/addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py @@ -18,7 +18,7 @@ class AccountEdiXmlCII(models.AbstractModel): _description = "Factur-x/XRechnung CII 2.2.0" def _export_invoice_filename(self, invoice): - return "factur-x.xml" + return f"{invoice.name.replace('/', '_')}_factur_x.xml" def _export_invoice_ecosio_schematrons(self): return { diff --git a/addons/l10n_account_edi_ubl_cii_tests/tests/test_xml_cii_fr.py b/addons/l10n_account_edi_ubl_cii_tests/tests/test_xml_cii_fr.py index 69c731f5ee5..48395dc920c 100644 --- a/addons/l10n_account_edi_ubl_cii_tests/tests/test_xml_cii_fr.py +++ b/addons/l10n_account_edi_ubl_cii_tests/tests/test_xml_cii_fr.py @@ -137,7 +137,8 @@ class TestCIIFR(TestUBLCommon): ) pdf_attachment = invoice.ubl_cii_xml_id - self.assertEqual(pdf_attachment['name'], 'factur-x.xml') + facturx_filename = self.env['account.edi.xml.cii']._export_invoice_filename(invoice) + self.assertEqual(pdf_attachment['name'], facturx_filename) def test_export_import_invoice(self): invoice = self._generate_move( @@ -184,7 +185,8 @@ class TestCIIFR(TestUBLCommon): ''', expected_file_path='from_odoo/facturx_out_invoice.xml', ) - self.assertEqual(attachment.name, "factur-x.xml") + facturx_filename = self.env['account.edi.xml.cii']._export_invoice_filename(invoice) + self.assertEqual(attachment.name, facturx_filename) self._assert_imported_invoice_from_etree(invoice, attachment) def test_export_import_refund(self): @@ -229,7 +231,8 @@ class TestCIIFR(TestUBLCommon): ''', expected_file_path='from_odoo/facturx_out_refund.xml' ) - self.assertEqual(attachment.name, "factur-x.xml") + facturx_filename = self.env['account.edi.xml.cii']._export_invoice_filename(refund) + self.assertEqual(attachment.name, facturx_filename) self._assert_imported_invoice_from_etree(refund, attachment) def test_export_tax_included(self): @@ -290,7 +293,8 @@ class TestCIIFR(TestUBLCommon): move_type='out_invoice', invoice_line_ids=[{'product_id': self.product_a.id}], ) - self._test_encoding_in_attachment(invoice.ubl_cii_xml_id, 'factur-x.xml') + facturx_filename = self.env['account.edi.xml.cii']._export_invoice_filename(invoice) + self._test_encoding_in_attachment(invoice.ubl_cii_xml_id, facturx_filename) def test_export_with_fixed_taxes_case1(self): # CASE 1: simple invoice with a recupel tax