@@ -100,12 +100,18 @@ class Report(Document): | |||||
data = frappe.desk.query_report.run(self.name, filters=filters, user=user) | data = frappe.desk.query_report.run(self.name, filters=filters, user=user) | ||||
for d in data.get('columns'): | for d in data.get('columns'): | ||||
if isinstance(d, dict): | if isinstance(d, dict): | ||||
columns.append(frappe._dict(d)) | |||||
col = frappe._dict(d) | |||||
if not col.fieldname: | |||||
col.fieldname = col.label | |||||
columns.append(col) | |||||
else: | else: | ||||
fieldtype, options = "Data", None | |||||
parts = d.split(':') | parts = d.split(':') | ||||
fieldtype, options = parts[1], None | |||||
if fieldtype and '/' in fieldtype: | |||||
fieldtype, options = fieldtype.split('/') | |||||
if len(parts) > 1: | |||||
if parts[1]: | |||||
fieldtype, options = parts[1], None | |||||
if fieldtype and '/' in fieldtype: | |||||
fieldtype, options = fieldtype.split('/') | |||||
columns.append(frappe._dict(label=parts[0], fieldtype=fieldtype, fieldname=parts[0])) | columns.append(frappe._dict(label=parts[0], fieldtype=fieldtype, fieldname=parts[0])) | ||||
@@ -145,7 +151,7 @@ class Report(Document): | |||||
for c in columns] | for c in columns] | ||||
out = out + [list(d) for d in result] | out = out + [list(d) for d in result] | ||||
if as_dict: | if as_dict: | ||||
data = [] | data = [] | ||||
for row in out: | for row in out: | ||||
@@ -155,7 +161,6 @@ class Report(Document): | |||||
_row[columns[i].get('fieldname')] = val | _row[columns[i].get('fieldname')] = val | ||||
else: | else: | ||||
data = out | data = out | ||||
return columns, data | return columns, data | ||||
@@ -104,7 +104,7 @@ def run(report_name, filters=None, user=None): | |||||
if cint(report.add_total_row) and result: | if cint(report.add_total_row) and result: | ||||
result = add_total_row(result, columns) | result = add_total_row(result, columns) | ||||
return { | return { | ||||
"result": result, | "result": result, | ||||
"columns": columns, | "columns": columns, | ||||
@@ -185,9 +185,12 @@ def add_total_row(result, columns, meta = None): | |||||
else: | else: | ||||
col = col.split(":") | col = col.split(":") | ||||
if len(col) > 1: | if len(col) > 1: | ||||
fieldtype = col[1] | |||||
if "/" in fieldtype: | |||||
fieldtype, options = fieldtype.split("/") | |||||
if col[1]: | |||||
fieldtype = col[1] | |||||
if "/" in fieldtype: | |||||
fieldtype, options = fieldtype.split("/") | |||||
else: | |||||
fieldtype = "Data" | |||||
else: | else: | ||||
fieldtype = col.get("fieldtype") | fieldtype = col.get("fieldtype") | ||||
options = col.get("options") | options = col.get("options") | ||||
@@ -213,7 +216,7 @@ def add_total_row(result, columns, meta = None): | |||||
else: | else: | ||||
first_col_fieldtype = columns[0].get("fieldtype") | first_col_fieldtype = columns[0].get("fieldtype") | ||||
if first_col_fieldtype not in ["Currency", "Int", "Float", "Percent"]: | |||||
if first_col_fieldtype not in ["Currency", "Int", "Float", "Percent", "Date"]: | |||||
if first_col_fieldtype == "Link": | if first_col_fieldtype == "Link": | ||||
total_row[0] = "'" + _("Total") + "'" | total_row[0] = "'" + _("Total") + "'" | ||||
else: | else: | ||||
@@ -124,9 +124,9 @@ class AutoEmailReport(Document): | |||||
report_doctype = frappe.db.get_value('Report', self.report, 'ref_doctype') | report_doctype = frappe.db.get_value('Report', self.report, 'ref_doctype') | ||||
report_footer = frappe.render_template(self.get_report_footer(), | report_footer = frappe.render_template(self.get_report_footer(), | ||||
dict(report_url = frappe.utils.get_url_to_report(self.report, self.report_type, report_doctype), | |||||
report_name = self.report, | |||||
edit_report_settings = frappe.utils.get_link_to_form('Auto Email Report', self.name))) | |||||
dict(report_url = frappe.utils.get_url_to_report(self.report, self.report_type, report_doctype), | |||||
report_name = self.report, | |||||
edit_report_settings = frappe.utils.get_link_to_form('Auto Email Report', self.name))) | |||||
message += report_footer | message += report_footer | ||||
@@ -432,7 +432,8 @@ def prepare_message(email, recipient, recipients_list): | |||||
if email.add_unsubscribe_link and email.reference_doctype: # is missing the check for unsubscribe message but will not add as there will be no unsubscribe url | if email.add_unsubscribe_link and email.reference_doctype: # is missing the check for unsubscribe message but will not add as there will be no unsubscribe url | ||||
unsubscribe_url = get_unsubcribed_url(email.reference_doctype, email.reference_name, recipient, | unsubscribe_url = get_unsubcribed_url(email.reference_doctype, email.reference_name, recipient, | ||||
email.unsubscribe_method, email.unsubscribe_params) | email.unsubscribe_method, email.unsubscribe_params) | ||||
message = message.replace("<!--unsubscribe url-->", quopri.encodestring(unsubscribe_url)) | |||||
if message: | |||||
message = message.replace("<!--unsubscribe url-->", quopri.encodestring(unsubscribe_url)) | |||||
if email.expose_recipients == "header": | if email.expose_recipients == "header": | ||||
pass | pass | ||||