From 6bbec45fb09a00e0e32d5b56a856a258560c5004 Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:49:49 +0100 Subject: [PATCH] feat: attach eInvoice if possible --- .../datev_unternehmen_online_settings.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/erpnext_datev/erpnext_datev/doctype/datev_unternehmen_online_settings/datev_unternehmen_online_settings.py b/erpnext_datev/erpnext_datev/doctype/datev_unternehmen_online_settings/datev_unternehmen_online_settings.py index 26c6a53..3abde51 100644 --- a/erpnext_datev/erpnext_datev/doctype/datev_unternehmen_online_settings/datev_unternehmen_online_settings.py +++ b/erpnext_datev/erpnext_datev/doctype/datev_unternehmen_online_settings/datev_unternehmen_online_settings.py @@ -68,6 +68,16 @@ def attach_print(doctype, name, language, print_format): with print_language(language): data = frappe.get_print(doctype, name, print_format, as_pdf=True) + if doctype == "Sales Invoice" and "eu_einvoice" in frappe.get_installed_apps(): + try: + from eu_einvoice.european_e_invoice.custom.sales_invoice import attach_xml_to_pdf + + data = attach_xml_to_pdf(name, data) + except Exception: + msg = _("Failed to attach XML to Sales Invoice PDF for DATEV") + frappe.log_error(title=msg, reference_doctype=doctype, reference_name=name) + frappe.msgprint(msg, indicator="red", alert=True) + file = frappe.new_doc("File") file.file_name = f"{name}.pdf" file.content = data