import openerp.modules
+def is_initialized(cr):
+ """ Check if a database has been initialized for the ORM.
+
+ The database can be initialized with the 'initialize' function below.
+
+ """
+ cr.execute("SELECT relname FROM pg_class WHERE relkind='r' AND relname='ir_module_module'")
+ return len(cr.fetchall()) > 0
+
def initialize(cr):
""" Initialize a database with for the ORM.
open_openerp_namespace()
+ force = []
+ if force_demo:
+ force.append('demo')
+
cr = db.cursor()
- if cr:
- cr.execute("SELECT relname FROM pg_class WHERE relkind='r' AND relname='ir_module_module'")
- if len(cr.fetchall())==0:
+ try:
+ if not openerp.modules.db.is_initialized(cr):
logger.notifyChannel("init", netsvc.LOG_INFO, "init db")
openerp.modules.db.initialize(cr)
tools.config["init"]["all"] = 1
tools.config['update']['all'] = 1
if not tools.config['without_demo']:
tools.config["demo"]['all'] = 1
- force = []
- if force_demo:
- force.append('demo')
- # This is a brand new pool, just created in pooler.get_db_and_pool()
- pool = pooler.get_pool(cr.dbname)
+ # This is a brand new pool, just created in pooler.get_db_and_pool()
+ pool = pooler.get_pool(cr.dbname)
- try:
processed_modules = []
report = tools.assertion_report()
# NOTE: Try to also load the modules that have been marked as uninstallable previously...
cr = None
try:
serv.actions[id]['progress'] = 0
- cr = sql_db.db_connect(db_name).cursor()
- openerp.modules.db.initialize(cr)
tools.config['lang'] = lang
- cr.commit()
- cr.close()
- cr = None
pool = pooler.restart_pool(db_name, demo, serv.actions[id],
update_module=True)[1]