Merge pull request #688 from anandpdoshi/print-as-pdf-optional
Option in Outgoing Email Settings to Send Attached Document Print as PDF
This commit is contained in:
commit
693ddcf64b
4 changed files with 32 additions and 5 deletions
|
|
@ -129,10 +129,16 @@ def send_comm_email(d, name, sent_via=None, print_html=None, attachments='[]', s
|
|||
if print_html:
|
||||
print_html = scrub_urls(print_html)
|
||||
|
||||
try:
|
||||
mail.add_pdf_attachment(name.replace(' ','').replace('/','-') + '.pdf', print_html)
|
||||
except Exception:
|
||||
frappe.msgprint(_("Error generating PDF, attachment sent as HTML"))
|
||||
send_print_as_pdf = cint(frappe.db.get_value("Outgoing Email Settings", "Outgoing Email Settings", "send_print_as_pdf"))
|
||||
|
||||
if send_print_as_pdf:
|
||||
try:
|
||||
mail.add_pdf_attachment(name.replace(' ','').replace('/','-') + '.pdf', print_html)
|
||||
except Exception:
|
||||
frappe.msgprint(_("Error generating PDF, attachment sent as HTML"))
|
||||
send_print_as_pdf = 0
|
||||
|
||||
if not send_print_as_pdf:
|
||||
mail.add_attachment(name.replace(' ','').replace('/','-') + '.html',
|
||||
print_html, 'text/html')
|
||||
|
||||
|
|
|
|||
|
|
@ -74,6 +74,12 @@
|
|||
"label": "Auto Email Id",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "send_print_as_pdf",
|
||||
"fieldtype": "Check",
|
||||
"label": "Send Attached Document Print as PDF",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"fieldname": "section_break_10",
|
||||
"fieldtype": "Section Break",
|
||||
|
|
@ -92,7 +98,7 @@
|
|||
"idx": 1,
|
||||
"in_create": 1,
|
||||
"issingle": 1,
|
||||
"modified": "2014-07-07 11:42:10.128767",
|
||||
"modified": "2014-07-09 01:47:56.027654",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Core",
|
||||
"name": "Outgoing Email Settings",
|
||||
|
|
|
|||
|
|
@ -44,3 +44,4 @@ execute:frappe.reload_doc('website', 'doctype', 'website_route') #2014-06-17
|
|||
execute:frappe.db.sql("""update `tabProperty Setter` set property_type='Text' where property in ('options', 'default')""") #2014-06-20
|
||||
frappe.patches.v4_1.enable_outgoing_email_settings
|
||||
execute:frappe.db.sql("""update `tabSingles` set `value`=`doctype` where `field`='name'""") #2014-07-04
|
||||
frappe.patches.v4_1.enable_print_as_pdf
|
||||
|
|
|
|||
14
frappe/patches/v4_1/enable_print_as_pdf.py
Normal file
14
frappe/patches/v4_1/enable_print_as_pdf.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
# MIT License. See license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
frappe.reload_doc("core", "doctype", "outgoing_email_settings")
|
||||
try:
|
||||
import pdfkit
|
||||
except ImportError:
|
||||
pass
|
||||
else:
|
||||
frappe.db.set_value("Outgoing Email Settings", "Outgoing Email Settings", "send_print_as_pdf", 1)
|
||||
Loading…
Add table
Reference in a new issue