Merge pull request #1214 from anandpdoshi/hotfix-scheduler-errors
Send Email Digest, only if there is atleast one update for selected cate...
This commit is contained in:
commit
a38a7b8e76
@ -9,6 +9,7 @@ from webnotes.utils import fmt_money, formatdate, now_datetime, cstr, esc, \
|
|||||||
from webnotes.utils.dateutils import datetime_in_user_format
|
from webnotes.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 webnotes.utils.email_lib import sendmail
|
||||||
|
|
||||||
content_sequence = [
|
content_sequence = [
|
||||||
["Income / Expenses", ["income_year_to_date", "bank_balance",
|
["Income / Expenses", ["income_year_to_date", "bank_balance",
|
||||||
@ -80,15 +81,15 @@ class DocType(DocListController):
|
|||||||
for user_id in recipients:
|
for user_id in recipients:
|
||||||
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)
|
||||||
from webnotes.utils.email_lib import sendmail
|
if msg_for_this_receipient:
|
||||||
sendmail(recipients=user_id,
|
sendmail(recipients=user_id,
|
||||||
subject="[ERPNext] [{frequency} Digest] {name}".format(
|
subject="[ERPNext] [{frequency} Digest] {name}".format(
|
||||||
frequency=self.doc.frequency, name=self.doc.name),
|
frequency=self.doc.frequency, name=self.doc.name),
|
||||||
msg=msg_for_this_receipient)
|
msg=msg_for_this_receipient)
|
||||||
|
|
||||||
def get_digest_msg(self):
|
def get_digest_msg(self):
|
||||||
return self.get_msg_html(self.get_user_specific_content(webnotes.session.user) + \
|
return self.get_msg_html(self.get_user_specific_content(webnotes.session.user) + \
|
||||||
self.get_common_content())
|
self.get_common_content(), send_only_if_updates=False)
|
||||||
|
|
||||||
def get_common_content(self):
|
def get_common_content(self):
|
||||||
out = []
|
out = []
|
||||||
@ -119,14 +120,19 @@ class DocType(DocListController):
|
|||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def get_msg_html(self, out):
|
def get_msg_html(self, out, send_only_if_updates=True):
|
||||||
with_value = [o[1] for o in out if o[0]]
|
with_value = [o[1] for o in out if o[0]]
|
||||||
|
|
||||||
if with_value:
|
if with_value:
|
||||||
|
has_updates = True
|
||||||
with_value = "\n".join(with_value)
|
with_value = "\n".join(with_value)
|
||||||
else:
|
else:
|
||||||
|
has_updates = False
|
||||||
with_value = "<p>There were no updates in the items selected for this digest.</p><hr>"
|
with_value = "<p>There were no updates in the items selected for this digest.</p><hr>"
|
||||||
|
|
||||||
|
if not has_updates and send_only_if_updates:
|
||||||
|
return
|
||||||
|
|
||||||
# seperate out no value items
|
# seperate out no value items
|
||||||
no_value = [o[1] for o in out if not o[0]]
|
no_value = [o[1] for o in out if not o[0]]
|
||||||
if no_value:
|
if no_value:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user