From 8794a1233af4edaf09360030fea7e0f8498258f2 Mon Sep 17 00:00:00 2001 From: qdp Date: Thu, 6 Nov 2008 17:58:28 +0100 Subject: [PATCH] *improvement of import: *added try-except *bugfixed the import partial bzr revid: qdp@tinyerp.com-20081106165828-xldwvciacbp5u2zd --- bin/tools/convert.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/tools/convert.py b/bin/tools/convert.py index 06e49135d10..fe8afcc3594 100644 --- a/bin/tools/convert.py +++ b/bin/tools/convert.py @@ -784,7 +784,6 @@ def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init', input = StringIO.StringIO(csvcontent) reader = csv.reader(input, quotechar='"', delimiter=',') fields = reader.next() - fname_partial = "" if config.get('import_partial'): fname_partial = module + '/'+ fname @@ -807,13 +806,16 @@ def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init', for line in reader: if (not line) or not reduce(lambda x,y: x or y, line) : continue - datas.append( map(lambda x:x.decode('utf8').encode('utf8'), line)) + try: + datas.append( map(lambda x:x.decode('utf8').encode('utf8'), line)) + except: + print "ERROR while importing the line: ", line pool.get(model).import_data(cr, uid, fields, datas,mode, module,noupdate,filename=fname_partial) - if config.get('import_partial'): data = pickle.load(file(config.get('import_partial'))) data[fname_partial] = 0 pickle.dump(data, file(config.get('import_partial'),'wb')) + cr.commit() # # xml import/export