[refactor] used frappe.sendmail
This commit is contained in:
parent
5cdc8e560c
commit
bf8715dba4
@ -185,12 +185,10 @@ class SalarySlip(TransactionBase):
|
|||||||
|
|
||||||
|
|
||||||
def send_mail_funct(self):
|
def send_mail_funct(self):
|
||||||
from frappe.email import sendmail
|
|
||||||
|
|
||||||
receiver = frappe.db.get_value("Employee", self.employee, "company_email")
|
receiver = frappe.db.get_value("Employee", self.employee, "company_email")
|
||||||
if receiver:
|
if receiver:
|
||||||
subj = 'Salary Slip - ' + cstr(self.month) +'/'+cstr(self.fiscal_year)
|
subj = 'Salary Slip - ' + cstr(self.month) +'/'+cstr(self.fiscal_year)
|
||||||
sendmail([receiver], subject=subj, msg = _("Please see attachment"),
|
frappe.sendmail([receiver], subject=subj, msg = _("Please see attachment"),
|
||||||
attachments=[{
|
attachments=[{
|
||||||
"fname": self.name + ".pdf",
|
"fname": self.name + ".pdf",
|
||||||
"fcontent": frappe.get_print_format(self.doctype, self.name, as_pdf = True)
|
"fcontent": frappe.get_print_format(self.doctype, self.name, as_pdf = True)
|
||||||
|
|||||||
@ -57,7 +57,6 @@ def take_backups_gdrive():
|
|||||||
send_email(False, "Google Drive", error_message)
|
send_email(False, "Google Drive", error_message)
|
||||||
|
|
||||||
def send_email(success, service_name, error_status=None):
|
def send_email(success, service_name, error_status=None):
|
||||||
from frappe.email import sendmail
|
|
||||||
if success:
|
if success:
|
||||||
subject = "Backup Upload Successful"
|
subject = "Backup Upload Successful"
|
||||||
message ="""<h3>Backup Uploaded Successfully</h3><p>Hi there, this is just to inform you
|
message ="""<h3>Backup Uploaded Successfully</h3><p>Hi there, this is just to inform you
|
||||||
@ -76,4 +75,4 @@ def send_email(success, service_name, error_status=None):
|
|||||||
frappe.connect()
|
frappe.connect()
|
||||||
|
|
||||||
recipients = frappe.db.get_value("Backup Manager", None, "send_notifications_to").split(",")
|
recipients = frappe.db.get_value("Backup Manager", None, "send_notifications_to").split(",")
|
||||||
sendmail(recipients, subject=subject, msg=message)
|
frappe.sendmail(recipients=recipients, subject=subject, msg=message)
|
||||||
|
|||||||
@ -9,7 +9,6 @@ from frappe.utils import fmt_money, formatdate, now_datetime, cstr, esc, \
|
|||||||
from frappe.utils.dateutils import datetime_in_user_format
|
from frappe.utils.dateutils import datetime_in_user_format
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
from frappe.email import sendmail
|
|
||||||
from frappe.core.doctype.user.user import STANDARD_USERS
|
from frappe.core.doctype.user.user import STANDARD_USERS
|
||||||
|
|
||||||
content_sequence = [
|
content_sequence = [
|
||||||
@ -83,10 +82,10 @@ class EmailDigest(Document):
|
|||||||
msg_for_this_receipient = self.get_msg_html(self.get_user_specific_content(user_id) + \
|
msg_for_this_receipient = self.get_msg_html(self.get_user_specific_content(user_id) + \
|
||||||
common_msg)
|
common_msg)
|
||||||
if msg_for_this_receipient:
|
if msg_for_this_receipient:
|
||||||
sendmail(recipients=user_id,
|
frappe.sendmail(recipients=user_id,
|
||||||
subject="[ERPNext] [{frequency} Digest] {name}".format(
|
subject="[ERPNext] [{frequency} Digest] {name}".format(
|
||||||
frequency=self.frequency, name=self.name),
|
frequency=self.frequency, name=self.name),
|
||||||
msg=msg_for_this_receipient)
|
msg=msg_for_this_receipient, bulk=True)
|
||||||
|
|
||||||
def get_digest_msg(self):
|
def get_digest_msg(self):
|
||||||
return self.get_msg_html(self.get_user_specific_content(frappe.session.user) + \
|
return self.get_msg_html(self.get_user_specific_content(frappe.session.user) + \
|
||||||
|
|||||||
@ -6,7 +6,6 @@ from frappe import _
|
|||||||
import json
|
import json
|
||||||
from frappe.utils import flt, cstr, nowdate, add_days, cint
|
from frappe.utils import flt, cstr, nowdate, add_days, cint
|
||||||
from frappe.defaults import get_global_default
|
from frappe.defaults import get_global_default
|
||||||
from frappe.email import sendmail
|
|
||||||
from erpnext.accounts.utils import get_fiscal_year, FiscalYearError
|
from erpnext.accounts.utils import get_fiscal_year, FiscalYearError
|
||||||
|
|
||||||
class InvalidWarehouseCompany(frappe.ValidationError): pass
|
class InvalidWarehouseCompany(frappe.ValidationError): pass
|
||||||
@ -336,11 +335,11 @@ def send_email_notification(mr_list):
|
|||||||
msg += "<tr><td>" + item.item_code + "</td><td>" + item.warehouse + "</td><td>" + \
|
msg += "<tr><td>" + item.item_code + "</td><td>" + item.warehouse + "</td><td>" + \
|
||||||
cstr(item.qty) + "</td><td>" + cstr(item.uom) + "</td></tr>"
|
cstr(item.qty) + "</td><td>" + cstr(item.uom) + "</td></tr>"
|
||||||
msg += "</table>"
|
msg += "</table>"
|
||||||
sendmail(email_list, subject='Auto Material Request Generation Notification', msg = msg)
|
frappe.sendmail(recipients=email_list, subject='Auto Material Request Generation Notification', msg = msg)
|
||||||
|
|
||||||
def notify_errors(exceptions_list):
|
def notify_errors(exceptions_list):
|
||||||
subject = "[Important] [ERPNext] Error(s) while creating Material Requests based on Re-order Levels"
|
subject = "[Important] [ERPNext] Error(s) while creating Material Requests based on Re-order Levels"
|
||||||
msg = """Dear System Manager,
|
content = """Dear System Manager,
|
||||||
|
|
||||||
An error occured for certain Items while creating Material Requests based on Re-order level.
|
An error occured for certain Items while creating Material Requests based on Re-order level.
|
||||||
|
|
||||||
@ -353,5 +352,5 @@ Please rectify these issues:
|
|||||||
Regards,
|
Regards,
|
||||||
Administrator""" % ("\n\n".join(exceptions_list),)
|
Administrator""" % ("\n\n".join(exceptions_list),)
|
||||||
|
|
||||||
from frappe.utils.user import get_system_managers
|
from frappe.email import sendmail_to_system_managers
|
||||||
sendmail(get_system_managers(), subject=subject, msg=msg)
|
sendmail_to_system_managers(subject, content)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user