diff --git a/accounts/page/voucher_import_tool/voucher_import_tool.py b/accounts/page/voucher_import_tool/voucher_import_tool.py index 1819e077055..2d7cd25fd1e 100644 --- a/accounts/page/voucher_import_tool/voucher_import_tool.py +++ b/accounts/page/voucher_import_tool/voucher_import_tool.py @@ -1,6 +1,6 @@ from __future__ import unicode_literals import webnotes -from webnotes.utils import flt +from webnotes.utils import flt, comma_and @webnotes.whitelist() def get_template(): @@ -231,6 +231,14 @@ def get_data(rows, company_abbr): if r[0]=="--------Data----------": start_row = i+2 + + # check for empty columns + empty_columns = [i+1 for i, c in enumerate(rows[i+1]) if not c] + if empty_columns: + raise Exception, """Column No(s). %s %s empty. \ + Please remove them and try again.""" % (comma_and(empty_columns), + len(empty_columns)==1 and "is" or "are") + columns = [c.replace(" ", "_").lower() for c in rows[i+1] if not c.endswith(" - " + company_abbr)] accounts = [c for c in rows[i+1] if c.endswith(" - " + company_abbr)]