Преглед на файлове

fix(Data Import): don't validate empty values (#17923) (#18275)

* refactor: exclude header from column values earlier

* fix: don't validate empty columns

Co-authored-by: Ankush Menat <ankush@frappe.io>
(cherry picked from commit 513321810d)

Co-authored-by: Raffael Meyer <14891507+barredterra@users.noreply.github.com>
version-14
mergify[bot] преди 2 години
committed by GitHub
родител
ревизия
26bfbf0cfc
No known key found for this signature in database GPG ключ ID: 4AEE18F83AFDEB23
променени са 1 файла, в които са добавени 6 реда и са изтрити 3 реда
  1. +6
    -3
      frappe/core/doctype/data_import/importer.py

+ 6
- 3
frappe/core/doctype/data_import/importer.py Целия файл

@@ -449,7 +449,7 @@ class ImportFile:
continue

if not header:
header = Header(i, row, self.doctype, self.raw_data, self.column_to_field_map)
header = Header(i, row, self.doctype, self.raw_data[1:], self.column_to_field_map)
else:
row_obj = Row(i, row, self.doctype, header, self.import_type)
data.append(row_obj)
@@ -981,9 +981,12 @@ class Column:
if self.skip_import:
return

if not any(self.column_values):
return

if self.df.fieldtype == "Link":
# find all values that dont exist
values = list({cstr(v) for v in self.column_values[1:] if v})
values = list({cstr(v) for v in self.column_values if v})
exists = [
cstr(d.name) for d in frappe.get_all(self.df.options, filters={"name": ("in", values)})
]
@@ -1022,7 +1025,7 @@ class Column:
elif self.df.fieldtype == "Select":
options = get_select_options(self.df)
if options:
values = {cstr(v) for v in self.column_values[1:] if v}
values = {cstr(v) for v in self.column_values if v}
invalid = values - set(options)
if invalid:
valid_values = ", ".join(frappe.bold(o) for o in options)


Зареждане…
Отказ
Запис