Skip to content

Commit

Permalink
handle empty rows, validating naming-series
Browse files Browse the repository at this point in the history
  • Loading branch information
Zlash65 committed Nov 27, 2017
1 parent b1e25ee commit ce60450
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion frappe/core/page/data_import_tool/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,21 @@ def get_doc(start_idx):
return doc

def main_doc_empty(row):
return not (row and ((len(row) > 1 and row[1]) or (len(row) > 2 and row[2])))
return not (row and filter(None, row))

def validate_naming(doc):
autoname = frappe.get_meta(doc['doctype']).autoname

if ".#####" in autoname or "hash" in autoname:
autoname = ""
elif autoname[0:5] == 'field':
autoname = autoname[6:]
elif ":" in autoname:
autoname = autoname[:len(autoname)-1]

if autoname and not doc[autoname]:
frappe.throw(_("{0} is a mandatory field".format(autoname)))
return True

users = frappe.db.sql_list("select name from tabUser")
def prepare_for_insert(doc):
Expand Down Expand Up @@ -307,6 +321,7 @@ def as_link(doctype, name):

try:
doc = get_doc(row_idx)
validate_naming(doc)
if pre_process:
pre_process(doc)

Expand Down

0 comments on commit ce60450

Please sign in to comment.