*improvement of import:

*added try-except
	*bugfixed the import partial

bzr revid: qdp@tinyerp.com-20081106165828-xldwvciacbp5u2zd
This commit is contained in:
qdp 2008-11-06 17:58:28 +01:00
parent 842bd1e101
commit 8794a1233a
1 changed files with 5 additions and 3 deletions

View File

@ -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