chore: code cleanup

This commit is contained in:
RitvikSardana 2023-09-18 18:24:43 +05:30
parent 4bbed3287e
commit 7ae5ffca19

View file

@ -223,11 +223,12 @@ def run(
def add_custom_column_data(custom_columns, result):
doctype_name_from_custom_field = []
doctype_names_from_custom_field = []
for column in custom_columns:
doctype_name_from_custom_field.append(frappe.unscrub(column["fieldname"].split("-")[1])) if len(
column["fieldname"].split("-")
) > 1 else None
if len(column["fieldname"].split("-")) > 1:
# length greater than 1, means that the column is a custom field with confilicting fieldname
doctype_name = frappe.unscrub(column["fieldname"].split("-")[1])
doctype_names_from_custom_field.append(doctype_name)
column["fieldname"] = column["fieldname"].split("-")[0]
custom_column_data = get_data_for_custom_report(custom_columns, result)
@ -247,7 +248,7 @@ def add_custom_column_data(custom_columns, result):
# possible if the row is empty
if not row_reference:
continue
if key[0] in doctype_name_from_custom_field:
if key[0] in doctype_names_from_custom_field:
column["fieldname"] = column.get("id")
row[column.get("fieldname")] = custom_column_data.get(key).get(row_reference)