From 548dd08c59c24776488a920481c3bd98b5efcf5f Mon Sep 17 00:00:00 2001 From: ced <> Date: Thu, 20 Sep 2007 08:47:44 +0000 Subject: [PATCH] Process all the csv file in one step prevent to cut a one2many line bzr revid: ced-0a86524706e498aa4ce58260df97daf40bba0165 --- bin/tools/convert.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/bin/tools/convert.py b/bin/tools/convert.py index 7f3f5723231..c278b7c9dae 100644 --- a/bin/tools/convert.py +++ b/bin/tools/convert.py @@ -608,9 +608,8 @@ class xml_import(object): 'act_window': self._tag_act_window, } -CSV_STEP = 500 - -def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init', noupdate=False): +def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init', + noupdate=False): '''Import csv file : quote: " delimiter: , @@ -623,7 +622,7 @@ def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init', n pool = pooler.get_pool(cr.dbname) - input=StringIO.StringIO(csvcontent) + input = StringIO.StringIO(csvcontent) reader = csv.reader(input, quotechar='"', delimiter=',') fields = reader.next() @@ -634,11 +633,7 @@ def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init', n datas = [] for line in reader: datas.append( map(lambda x:x.decode('utf8').encode('utf8'), line)) - if len(datas) > CSV_STEP: - pool.get(model).import_data(cr, uid, fields, datas,mode, module,noupdate) - datas=[] - if datas: - pool.get(model).import_data(cr, uid, fields, datas,mode, module,noupdate) + pool.get(model).import_data(cr, uid, fields, datas,mode, module,noupdate) # # xml import/export