[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) <las@odoo.com>
This commit is contained in:
Claire Bretton (clbr)
2024-04-24 09:28:15 +00:00
parent 8fadfe88bd
commit aa2d54d001
2 changed files with 9 additions and 5 deletions
@@ -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 {
@@ -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