From a648945d72cfad1bad2a116fec61225555f8a544 Mon Sep 17 00:00:00 2001 From: Raffael Meyer <14891507+barredterra@users.noreply.github.com> Date: Thu, 5 Dec 2024 12:15:06 +0100 Subject: [PATCH] feat: einvoice integration (#48) If the app "eu_einvoice" is installed, use it's `attach_xml_to_pdf` method when creating PDFs for Sales Invoice. --- pdf_on_submit/attach_pdf.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pdf_on_submit/attach_pdf.py b/pdf_on_submit/attach_pdf.py index 0cbb1ed..2c40e52 100644 --- a/pdf_on_submit/attach_pdf.py +++ b/pdf_on_submit/attach_pdf.py @@ -93,6 +93,16 @@ def publish_progress(percent): else: pdf_data = get_pdf_data(doctype, name, print_format, letter_head) + 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 + pdf_data = attach_xml_to_pdf(name, pdf_data) + except Exception: + msg = _("Failed to attach XML to PDF for Sales Invoice {0}").format(name) + if show_progress: + frappe.msgprint(msg, indicator="red", alert=True) + frappe.log_error(title=msg) + if show_progress: publish_progress(66)