Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(RFQ): optionally send document print (backport #36363) #36755

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,24 @@ 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()

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):
Expand All @@ -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,
Expand Down
Loading