Skip to content

Commit

Permalink
[IMP] datev_export_xml: Add xml declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
fkantelberg committed May 27, 2024
1 parent e1ebc4b commit cd01697
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions datev_export_xml/models/datev_xml_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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")
4 changes: 2 additions & 2 deletions datev_export_xml/tests/test_datev_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit cd01697

Please sign in to comment.