Skip to content

Commit

Permalink
fix: Strip spaces from label for column matching
Browse files Browse the repository at this point in the history
  • Loading branch information
netchampfaris committed Jul 6, 2020
1 parent 785ff48 commit a71f9cd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions frappe/core/doctype/data_import/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,7 @@ def get_standard_fields(doctype):
# other fields
fields = get_standard_fields(doctype) + frappe.get_meta(doctype).fields
for df in fields:
label = (df.label or '').strip()
fieldtype = df.fieldtype or "Data"
parent = df.parent or parent_doctype
if fieldtype not in no_value_fields:
Expand All @@ -1068,12 +1069,12 @@ def get_standard_fields(doctype):
# Label
# label
# Label (label)
if not out.get(df.label):
if not out.get(label):
# if Label is already set, don't set it again
# in case of duplicate column headers
out[df.label] = df
out[label] = df
out[df.fieldname] = df
label_with_fieldname = "{0} ({1})".format(df.label, df.fieldname)
label_with_fieldname = "{0} ({1})".format(label, df.fieldname)
out[label_with_fieldname] = df
else:
# in case there are multiple table fields with the same doctype
Expand All @@ -1084,7 +1085,7 @@ def get_standard_fields(doctype):
"fields", {"fieldtype": ["in", table_fieldtypes], "options": parent}
)
for table_field in table_fields:
by_label = "{0} ({1})".format(df.label, table_field.label)
by_label = "{0} ({1})".format(label, table_field.label)
by_fieldname = "{0}.{1}".format(table_field.fieldname, df.fieldname)

# create a new df object to avoid mutation problems
Expand Down

0 comments on commit a71f9cd

Please sign in to comment.