From e5ae4d3bd31f79be5fe8a22f61fb61269c35ad4b Mon Sep 17 00:00:00 2001 From: Makarand Bauskar Date: Mon, 14 Aug 2017 12:22:50 +0530 Subject: [PATCH 1/2] send email via the background jobs (#10374) (#10393) * send the email via the background worker in the payment request (#10350) * send email via the background jobs (#10374) --- .../doctype/payment_request/payment_request.py | 13 ++++++++++--- erpnext/hr/doctype/salary_slip/salary_slip.py | 13 ++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py index a0efac5318..421bd176ec 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request.py +++ b/erpnext/accounts/doctype/payment_request/payment_request.py @@ -11,6 +11,7 @@ from erpnext.accounts.party import get_party_account from erpnext.accounts.utils import get_account_currency from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry, get_company_defaults from frappe.integrations.utils import get_payment_gateway_controller +from frappe.utils.background_jobs import enqueue class PaymentRequest(Document): def validate(self): @@ -142,9 +143,15 @@ class PaymentRequest(Document): def send_email(self): """send email with payment link""" - frappe.sendmail(recipients=self.email_to, sender=None, subject=self.subject, - message=self.get_message(), attachments=[frappe.attach_print(self.reference_doctype, - self.reference_name, file_name=self.reference_name, print_format=self.print_format)]) + email_args = { + "recipients": self.email_to, + "sender": None, + "subject": self.subject, + "message": self.get_message(), + "now": True, + "attachments": [frappe.attach_print(self.reference_doctype, self.reference_name, + file_name=self.reference_name, print_format=self.print_format)]} + enqueue(method=frappe.sendmail, queue='short', timeout=300, async=True, **email_args) def get_message(self): """return message with payment gateway link""" diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py index 2bd08c22c1..1d17613381 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.py +++ b/erpnext/hr/doctype/salary_slip/salary_slip.py @@ -11,6 +11,7 @@ from frappe import msgprint, _ from erpnext.hr.doctype.process_payroll.process_payroll import get_start_end_dates from erpnext.hr.doctype.employee.employee import get_holiday_list_for_employee from erpnext.utilities.transaction_base import TransactionBase +from frappe.utils.background_jobs import enqueue class SalarySlip(TransactionBase): def autoname(self): @@ -396,9 +397,15 @@ class SalarySlip(TransactionBase): receiver = frappe.db.get_value("Employee", self.employee, "prefered_email") if receiver: - subj = 'Salary Slip - from {0} to {1}'.format(self.start_date, self.end_date) - frappe.sendmail([receiver], subject=subj, message = _("Please see attachment"), - attachments=[frappe.attach_print(self.doctype, self.name, file_name=self.name)], reference_doctype= self.doctype, reference_name= self.name) + email_args = { + "recipients": [receiver], + "message": _("Please see attachment"), + "subject": 'Salary Slip - from {0} to {1}'.format(self.start_date, self.end_date), + "attachments": [frappe.attach_print(self.doctype, self.name, file_name=self.name)], + "reference_doctype": self.doctype, + "reference_name": self.name + } + enqueue(method=frappe.sendmail, queue='short', timeout=300, async=True, **email_args) else: msgprint(_("{0}: Employee email not found, hence email not sent").format(self.employee_name)) From e0cc7c64a161c20a6680a4ded6afe94f0886e16a Mon Sep 17 00:00:00 2001 From: mbauskar Date: Mon, 14 Aug 2017 13:03:55 +0600 Subject: [PATCH 2/2] bumped to version 8.8.3 --- erpnext/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index f9e2c16684..fb7c761e4f 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -4,7 +4,7 @@ import inspect import frappe from erpnext.hooks import regional_overrides -__version__ = '8.8.2' +__version__ = '8.8.3' def get_default_company(user=None): '''Get default company for user'''