From 29785af9158e3e28b435546b869af62df27869d2 Mon Sep 17 00:00:00 2001 From: abdgad Date: Sat, 6 Nov 2021 11:41:46 +0100 Subject: [PATCH] refactor: minor code cleanup in auto_email_report.py --- .../doctype/auto_email_report/auto_email_report.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/frappe/email/doctype/auto_email_report/auto_email_report.py b/frappe/email/doctype/auto_email_report/auto_email_report.py index 7081a84e7a..066f446dd4 100644 --- a/frappe/email/doctype/auto_email_report/auto_email_report.py +++ b/frappe/email/doctype/auto_email_report/auto_email_report.py @@ -242,13 +242,16 @@ def make_links(columns, data): for row in data: doc_name = row.get('name') for col in columns: - if col.fieldtype == "Link" and col.options != "Currency": - if col.options and row.get(col.fieldname): + if not row.get(col.fieldname): + continue + + if col.fieldtype == "Link": + if col.options and col.options != "Currency": row[col.fieldname] = get_link_to_form(col.options, row[col.fieldname]) elif col.fieldtype == "Dynamic Link": - if col.options and row.get(col.fieldname) and row.get(col.options): + if col.options and row.get(col.options): row[col.fieldname] = get_link_to_form(row[col.options], row[col.fieldname]) - elif col.fieldtype == "Currency" and row.get(col.fieldname): + elif col.fieldtype == "Currency": doc = frappe.get_doc(col.parent, doc_name) if doc_name and col.parent else None # Pass the Document to get the currency based on docfield option row[col.fieldname] = frappe.format_value(row[col.fieldname], col, doc=doc)