From 12ba501178e56235ae7b2016378a47fdf2c0c2ac Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Tue, 21 Dec 2010 17:45:48 +0100 Subject: [PATCH] [FIX] convert: module install should fail when CSV import fails lp bug: https://launchpad.net/bugs/672669 fixed bzr revid: odo@openerp.com-20101221164548-za2o4239tk0xnrww --- bin/tools/convert.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/tools/convert.py b/bin/tools/convert.py index 7c72cc7c325..0faebd6aa9e 100644 --- a/bin/tools/convert.py +++ b/bin/tools/convert.py @@ -45,6 +45,8 @@ import netsvc import osv import pooler from config import config +from osv.orm import except_orm +from tools.translate import _ from yaml_import import convert_yaml_import # Import of XML records requires the unsafe eval as well, @@ -940,7 +942,10 @@ def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init', datas.append(map(lambda x: misc.ustr(x), line)) except: logger.error("Cannot import the line: %s", line) - pool.get(model).import_data(cr, uid, fields, datas,mode, module, noupdate, filename=fname_partial) + result, rows, warning_msg, dummy = pool.get(model).import_data(cr, uid, fields, datas,mode, module, noupdate, filename=fname_partial) + if result < 0: + # Report failed import and abort module install + raise except_orm(_('Module loading failed'), _('Loading %s/%s failed:\n %s') % (module, fname, warning_msg)) if config.get('import_partial'): data = pickle.load(file(config.get('import_partial'))) data[fname_partial] = 0