From 39a3c03b6233686fe7831d6bc981d233d2f95258 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 14 Jan 2013 15:26:51 +0530 Subject: [PATCH] if not a valid csv file, ignore it in stock reconciliation patch --- patches/january_2013/stock_reconciliation_patch.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/patches/january_2013/stock_reconciliation_patch.py b/patches/january_2013/stock_reconciliation_patch.py index 26d8f4f8bf..fa919f4598 100644 --- a/patches/january_2013/stock_reconciliation_patch.py +++ b/patches/january_2013/stock_reconciliation_patch.py @@ -58,8 +58,13 @@ def store_stock_reco_json(): if stock_reco_file_path: with open(stock_reco_file_path, "r") as open_reco_file: content = open_reco_file.read() - content = read_csv_content(content) - reconciliation_json = json.dumps(content, separators=(',', ': ')) - webnotes.conn.sql("""update `tabStock Reconciliation` - set reconciliation_json=%s where name=%s""", (reconciliation_json, reco)) + try: + content = read_csv_content(content) + reconciliation_json = json.dumps(content, separators=(',', ': ')) + webnotes.conn.sql("""update `tabStock Reconciliation` + set reconciliation_json=%s where name=%s""", + (reconciliation_json, reco)) + except Exception: + # if not a valid CSV file, do nothing + pass \ No newline at end of file