diff --git a/datev_export_xml/models/datev_xml_generator.py b/datev_export_xml/models/datev_xml_generator.py index 3349988a..4e2e6ea0 100644 --- a/datev_export_xml/models/datev_xml_generator.py +++ b/datev_export_xml/models/datev_xml_generator.py @@ -83,7 +83,9 @@ def generate_xml_document(self, invoices, check_xsd=True): "Document_v050.xsd", ) - return "document.xml", etree.tostring(root) + return "document.xml", etree.tostring( + root, xml_declaration=True, encoding="UTF-8" + ) @api.model def generate_xml_invoice(self, invoice, check_xsd=True): @@ -102,4 +104,4 @@ def generate_xml_invoice(self, invoice, check_xsd=True): invoice=invoice, ) - return doc_name, etree.tostring(root) + return doc_name, etree.tostring(root, xml_declaration=True, encoding="UTF-8") diff --git a/datev_export_xml/tests/test_datev_export.py b/datev_export_xml/tests/test_datev_export.py index 464021a3..6c8b4815 100644 --- a/datev_export_xml/tests/test_datev_export.py +++ b/datev_export_xml/tests/test_datev_export.py @@ -105,9 +105,9 @@ def _check_filecontent(self, export): doc_data = z.read(doc_file) inv_data = z.read(inv_file) # document.xml - doc_root = etree.fromstring(doc_data.decode("utf-8")) + doc_root = etree.fromstring(doc_data) # invoice.xml file - inv_root = etree.fromstring(inv_data.decode("utf-8")) + inv_root = etree.fromstring(inv_data) for i in inv_root: invoice_xml.update(i.attrib)