From 89e2ac4f477ee6f5c1de170e253188212437df2c Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 10 Jun 2013 17:58:33 +0530 Subject: [PATCH] [voucher import tool] [fix] validate account columns only for voucher import of type Multiple Accounts --- .../voucher_import_tool.py | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/accounts/page/voucher_import_tool/voucher_import_tool.py b/accounts/page/voucher_import_tool/voucher_import_tool.py index 7634e5bf84..a3790a8fe1 100644 --- a/accounts/page/voucher_import_tool/voucher_import_tool.py +++ b/accounts/page/voucher_import_tool/voucher_import_tool.py @@ -59,7 +59,7 @@ def upload(): if not company_abbr: webnotes.msgprint(_("Company is missing or entered incorrect value"), raise_exception=1) - data, start_idx = get_data(rows, company_abbr) + data, start_idx = get_data(rows, company_abbr, rows[0][0]) except Exception, e: err_msg = webnotes.message_log and "
".join(webnotes.message_log) or cstr(e) messages.append("""

%s

""" % (err_msg or "No message")) @@ -213,10 +213,11 @@ def get_common_values(rows): return common_values -def get_data(rows, company_abbr): +def get_data(rows, company_abbr, import_type): start_row = 0 data = [] start_row_idx = 0 + accounts = None for i in xrange(len(rows)): r = rows[i] if r[0]: @@ -257,17 +258,19 @@ def get_data(rows, company_abbr): 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)] + + if import_type == "Voucher Import: Multiple Accounts": + accounts = [c for c in rows[i+1] if c.endswith(" - " + company_abbr)] - if not accounts: - webnotes.msgprint(_("""No Account found in csv file, - May be company abbreviation is not correct"""), raise_exception=1) + if not accounts: + webnotes.msgprint(_("""No Account found in csv file, + May be company abbreviation is not correct"""), raise_exception=1) - if accounts and (len(columns) != rows[i+1].index(accounts[0])): - webnotes.msgprint(_("""All account columns should be after \ - standard columns and on the right. - If you entered it properly, next probable reason \ - could be wrong account name. - Please rectify it in the file and try again."""), raise_exception=1) + if accounts and (len(columns) != rows[i+1].index(accounts[0])): + webnotes.msgprint(_("""All account columns should be after \ + standard columns and on the right. + If you entered it properly, next probable reason \ + could be wrong account name. + Please rectify it in the file and try again."""), raise_exception=1) return data, start_row_idx \ No newline at end of file