From 83b19dbcec0b597e098e9fbe808f93fbf4b01903 Mon Sep 17 00:00:00 2001 From: Fabien Pinckaers Date: Tue, 19 Aug 2008 15:03:11 +0200 Subject: [PATCH] Support for Partial Commit bzr revid: fp@tinyerp.com-20080819130311-bzlschcnywx2voot --- bin/addons/__init__.py | 3 +++ bin/osv/orm.py | 42 +++++++++++++++++++++--------------------- bin/tools/convert.py | 8 +++++--- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/bin/addons/__init__.py b/bin/addons/__init__.py index 74ecc9a6f04..ec45981081b 100644 --- a/bin/addons/__init__.py +++ b/bin/addons/__init__.py @@ -327,6 +327,9 @@ def load_modules(db, force_demo=False, status=None, update_module=False): if force_demo: force.append('demo') if update_module: + for module in tools.config['init']: + cr.execute('update ir_module_module set state=%s where state=%s and name=%s', ('to install', 'uninstalled', module)) + cr.commit() cr.execute("select name from ir_module_module where state in ('installed', 'to install', 'to upgrade','to remove')") else: cr.execute("select name from ir_module_module where state in ('installed', 'to upgrade', 'to remove')") diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 5c312503c4f..198a3a17407 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -593,28 +593,28 @@ class orm_template(object): while len(datas): res = {} - try: - (res, other, warning, translate, data_id) = \ - process_liness(self, datas, [], fields_def) - if warning: - cr.rollback() - return (-1, res, warning, '') - id = self.pool.get('ir.model.data')._update(cr, uid, self._name, - current_module, res, xml_id=data_id, mode=mode, - noupdate=noupdate) - for lang in translate: - context2 = context.copy() - context2['lang'] = lang - self.write(cr, uid, [id], translate[lang], context2) - if config.get('commit_mode', False): - cr.commit() - except Exception, e: - logger.notifyChannel("import", netsvc.LOG_ERROR, e) + #try: + (res, other, warning, translate, data_id) = \ + process_liness(self, datas, [], fields_def) + if warning: cr.rollback() - try: - return (-1, res, e[0], warning) - except: - return (-1, res, e[0], '') + return (-1, res, warning, '') + id = self.pool.get('ir.model.data')._update(cr, uid, self._name, + current_module, res, xml_id=data_id, mode=mode, + noupdate=noupdate) + for lang in translate: + context2 = context.copy() + context2['lang'] = lang + self.write(cr, uid, [id], translate[lang], context2) + if config.get('import_partial', False): + cr.commit() + #except Exception, e: + # logger.notifyChannel("import", netsvc.LOG_ERROR, e) + # cr.rollback() + # try: + # return (-1, res, e[0], warning) + # except: + # return (-1, res, e[0], '') done += 1 # # TODO: Send a request with the result and multi-thread ! diff --git a/bin/tools/convert.py b/bin/tools/convert.py index 7ad2e9d93db..626052c060d 100644 --- a/bin/tools/convert.py +++ b/bin/tools/convert.py @@ -726,7 +726,9 @@ def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init', import pickle if config.get('import_partial'): - data = pickle.load(config.get('import_partial')) + if not os.path.isfile(config.get('import_partial')): + pickle.dump({}, file(config.get('import_partial'),'w+')) + data = pickle.load(file(config.get('import_partial'))) if fname in data: if not data[fname]: return @@ -746,9 +748,9 @@ def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init', datas.append( map(lambda x:x.decode('utf8').encode('utf8'), line)) pool.get(model).import_data(cr, uid, fields, datas,mode, module,noupdate) if config.get('import_partial'): - data = pickle.load(config.get('import_partial')) + data = pickle.load(file(config.get('import_partial'))) data[fname] = 0 - pickle.save(config.get('import_partial'), data) + pickle.dump(data, file(config.get('import_partial'),'wb')) # # xml import/export