diff --git a/erpnext/setup/doctype/email_digest/email_digest.py b/erpnext/setup/doctype/email_digest/email_digest.py
index 1a5e18f5b63..734b401d7e5 100644
--- a/erpnext/setup/doctype/email_digest/email_digest.py
+++ b/erpnext/setup/doctype/email_digest/email_digest.py
@@ -459,43 +459,13 @@ class DocType:
def table(args):
table_body = ""
+
if isinstance(args['body'], basestring):
- table_body = """\
-
- | """ + \
- args['body'] + \
- """\
- |
-
"""
+ return """%(head)s: %(body)s
""" % args
+ else:
+ return """%(head)s: """ +\
+ "".join(map(lambda b: "
%s
" % b, args['body']))
- elif isinstance(args['body'], list):
- body_rows = []
- for rows in args['body']:
- for r in rows:
- body_rows.append("""\
-
- | """ \
- + r + """\
- |
-
""")
-
- body_rows.append("
|
")
-
- table_body = "" + "".join(body_rows) + ""
-
- table_head = """\
-
- | """ \
- + args['head'] + """\
- |
-
"""
-
- return "" \
- + table_head \
- + table_body \
- + "
"
currency_amount_str = "%s %s"
@@ -669,50 +639,33 @@ class DocType:
new_section = False
+ def set_new_section(new_section):
+ if not new_section:
+ table_list.append("
No Updates For:
")
+ new_section = True
+ return new_section
+
for k in bd_keys:
if self.doc.fields[k]:
if k in result:
if not body_dict[k].get('value') and not new_section:
- if len(table_list) % 2 != 0:
- table_list.append("")
- table_list.append("
")
- table_list.append("
")
- new_section = True
+ new_section = set_new_section(new_section)
table_list.append(body_dict[k]['table'])
elif k in ['collections', 'payments']:
+ new_section = set_new_section(new_section)
table_list.append(\
- "[" + \
+ "
[" + \
k.capitalize() + \
"]
Missing: Account of type 'Bank or Cash'\
-
")
+ ")
elif k=='bank_balance':
+ new_section = set_new_section(new_section)
table_list.append(\
- "[" + \
+ "
[" + \
"Bank Balance" + \
"]
Alert: GL Entry not found for Account of type 'Bank or Cash'\
-
")
+ ")
-
- i = 0
- result = []
- op_len = len(table_list)
- while(True):
- if i>=op_len:
- break
- elif (op_len - i) == 1:
- result.append("""\
-
- | %s |
- |
-
""" % (table_list[i]))
- else:
- result.append("""\
-
- | %s |
- %s |
-
""" % (table_list[i], table_list[i+1]))
-
- i = i + 2
from webnotes.utils import formatdate
start_date, end_date = self.get_start_end_dates()
@@ -721,18 +674,16 @@ class DocType:
or (formatdate(str(start_date)) + " to " + (formatdate(str(end_date))))
email_body = """
-
-
-
""" \
+ %s
+ %s
+ %s
+
+ """ \
% ((self.doc.frequency + " Digest"), \
digest_daterange, self.doc.company) \
- + "".join(result) + """\
-
-
"""
+ + "".join(table_list) + """\
+
+ """
return email_body