From 6e02925b8293f91af7428ca5748711698c873878 Mon Sep 17 00:00:00 2001 From: Raffael Meyer <14891507+barredterra@users.noreply.github.com> Date: Tue, 22 Aug 2023 08:56:01 +0200 Subject: [PATCH 1/2] feat(RFQ): optionally send document print (#36363) (cherry picked from commit 4b75b6f30940b943919196624dd1f904cc142c88) --- .../request_for_quotation.json | 11 ++++++++++- .../request_for_quotation.py | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.json b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.json index fbfc1ac16935..06dbd86ba126 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.json +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.json @@ -25,6 +25,7 @@ "col_break_email_1", "html_llwp", "send_attached_files", + "send_document_print", "sec_break_email_2", "message_for_supplier", "terms_section_break", @@ -283,13 +284,21 @@ "fieldname": "send_attached_files", "fieldtype": "Check", "label": "Send Attached Files" + }, + { + "default": "0", + "description": "If enabled, a print of this document will be attached to each email", + "fieldname": "send_document_print", + "fieldtype": "Check", + "label": "Send Document Print", + "print_hide": 1 } ], "icon": "fa fa-shopping-cart", "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2023-08-08 16:30:10.870429", + "modified": "2023-08-09 12:20:26.850623", "modified_by": "Administrator", "module": "Buying", "name": "Request for Quotation", diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py index 56840c11a6e7..8ea415df19a3 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py @@ -209,6 +209,20 @@ def supplier_rfq_mail(self, data, update_password_link, rfq_link, preview=False) if self.send_attached_files: attachments = self.get_attachments() + if self.send_document_print: + supplier_language = frappe.db.get_value("Supplier", data.supplier, "language") + system_language = frappe.db.get_single_value("System Settings", "language") + attachments.append( + frappe.attach_print( + self.doctype, + self.name, + doc=self, + print_format=self.meta.default_print_format or "Standard", + lang=supplier_language or system_language, + letterhead=self.letter_head, + ) + ) + self.send_email(data, sender, subject, message, attachments) def send_email(self, data, sender, subject, message, attachments): @@ -218,7 +232,6 @@ def send_email(self, data, sender, subject, message, attachments): recipients=data.email_id, sender=sender, attachments=attachments, - print_format=self.meta.default_print_format or "Standard", send_email=True, doctype=self.doctype, name=self.name, From 4fdf35caca7a19c1df08fd149edb4d294913d79f Mon Sep 17 00:00:00 2001 From: barredterra <14891507+barredterra@users.noreply.github.com> Date: Tue, 22 Aug 2023 10:02:44 +0200 Subject: [PATCH 2/2] fix: attachments shold be an empty list by default --- .../doctype/request_for_quotation/request_for_quotation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py index 8ea415df19a3..6b39982bb816 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py @@ -205,7 +205,7 @@ def supplier_rfq_mail(self, data, update_password_link, rfq_link, preview=False) if preview: return {"message": message, "subject": subject} - attachments = None + attachments = [] if self.send_attached_files: attachments = self.get_attachments()