diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 14491110a04..793a91f05d4 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -59,6 +59,8 @@ import fields import ir import tools +from tools.config import config + prof = 0 ID_MAX = 1000 @@ -851,6 +853,8 @@ class orm(object): 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) cr.rollback() diff --git a/bin/tools/config.py b/bin/tools/config.py index 89bd01508c3..e76a10d960f 100644 --- a/bin/tools/config.py +++ b/bin/tools/config.py @@ -57,6 +57,7 @@ class configmanager(object): 'addons_path': None, 'root_path': None, 'debug_mode': False, + 'commit_mode': False, 'pidfile': None, 'logfile': None, 'secure': False, @@ -110,6 +111,7 @@ class configmanager(object): group.add_option("--db_host", dest="db_host", help="specify the database host") group.add_option("--db_port", dest="db_port", help="specify the database port") group.add_option("--db_maxconn", dest="db_maxconn", default='64', help="specify the the maximum number of physical connections to posgresql") + group.add_option("-C", "--commit-mode", dest="commit_mode", action="store_true", help="Several commit during one file importation. Use this for big data importation.", default=False) parser.add_option_group(group) group = optparse.OptionGroup(parser, "Internationalisation options", diff --git a/bin/tools/convert.py b/bin/tools/convert.py index f263e96eb86..c4c16c023f8 100644 --- a/bin/tools/convert.py +++ b/bin/tools/convert.py @@ -573,6 +573,8 @@ class xml_import(object): id = self.pool.get('ir.model.data')._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode ) if rec_id: self.idref[rec_id] = int(id) + if config.get('commit_mode', False): + cr.commit() return rec_model, id def id_get(self, cr, model, id_str):