Просмотр исходного кода

include the error data of the last row (#4649)

* include the error data of the last row

* set the attachment for each doc
version-14
Manas Solanki 7 лет назад
committed by Nabin Hait
Родитель
Сommit
50d7caedbb
2 измененных файлов: 7 добавлений и 28 удалений
  1. +0
    -24
      frappe/core/doctype/data_import/export_template.html
  2. +7
    -4
      frappe/core/doctype/data_import/importer.py

+ 0
- 24
frappe/core/doctype/data_import/export_template.html Просмотреть файл

@@ -1,24 +0,0 @@
<div style="margin: 15px 0px;">
<h4>{{ __("Select Columns Manually") }}</h4>
{% for doctype in doctype_list %}
<h5 style="margin-top: 25px; margin-bottom: 5px;">{{ doctype.name }}</h5>
<div class="row">
{% for f in doctype.fields %}
{% if (frappe.model.no_value_type.indexOf(f.fieldtype)===-1 && !f.hidden) %}
{% doctype.reqd||(f.reqd=0);%}
<div class="col-sm-6">
<div class="checkbox" style="margin: 5px 0px;">
<label>
<input type="checkbox" class="select-column-check"
data-fieldname="{{ f.fieldname }}" data-reqd="{{ f.reqd }}"
data-doctype="{{ doctype.name }}" checked>
<small>{{ __(f.label) }}</small>
</label>
</div>
</div>
{% endif %}
{% endfor %}
</div>
{% endfor %}
</div>

+ 7
- 4
frappe/core/doctype/data_import/importer.py Просмотреть файл

@@ -127,6 +127,8 @@ def upload(rows = None, submit_after_import=None, ignore_encoding_errors=False,
def get_doc(start_idx):
if doctypes:
doc = {}
attachments = []
last_error_row_idx = None
for idx in range(start_idx, len(rows)):
last_error_row_idx = idx # pylint: disable=W0612
if (not doc) or main_doc_empty(rows[idx]):
@@ -187,7 +189,7 @@ def upload(rows = None, submit_after_import=None, ignore_encoding_errors=False,
else:
break

return doc, last_error_row_idx
return doc, attachments, last_error_row_idx
else:
doc = frappe._dict(zip(columns, rows[start_idx][1:]))
doc['doctype'] = doctype
@@ -281,10 +283,8 @@ def upload(rows = None, submit_after_import=None, ignore_encoding_errors=False,
doctypes = []
column_idx_to_fieldname = {}
column_idx_to_fieldtype = {}
attachments = []

if skip_errors:
last_error_row_idx = None
data_rows_with_error = header

if submit_after_import and not cint(frappe.db.get_value("DocType",
@@ -354,7 +354,7 @@ def upload(rows = None, submit_after_import=None, ignore_encoding_errors=False,
publish_progress(i)

try:
doc, last_error_row_idx = get_doc(row_idx)
doc, attachments, last_error_row_idx = get_doc(row_idx)
validate_naming(doc)
if pre_process:
pre_process(doc)
@@ -416,7 +416,10 @@ def upload(rows = None, submit_after_import=None, ignore_encoding_errors=False,
log(**{"row": row_idx + 1, "title":'Error for row %s' % (len(row)>1 and row[1] or ""), "message": err_msg,
"indicator": "red", "link":error_link})
# data with error to create a new file
# include the errored data in the last row as last_error_row_idx will not be updated for the last row
if skip_errors:
if last_error_row_idx == len(rows)-1:
last_error_row_idx = len(rows)
data_rows_with_error += rows[row_idx:last_error_row_idx]
else:
rollback_flag = True


Загрузка…
Отмена
Сохранить