Merge pull request #14888 from abdgad/auto_email_report-cleanup

refactor: minor code cleanup in auto_email_report.py
This commit is contained in:
mergify[bot] 2021-11-08 05:31:44 +00:00 committed by GitHub
commit 177f85b4cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)