[FIX] base : Partner Addresses Menu now being translated
[odoo/odoo.git] / bin / pooler.py
index 250ee4f..75625f1 100644 (file)
@@ -1,8 +1,8 @@
 # -*- encoding: utf-8 -*-
 ##############################################################################
 #
-#    OpenERP, Open Source Management Solution  
-#    Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
+#    OpenERP, Open Source Management Solution
+#    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
 #    $Id$
 #
 #    This program is free software: you can redistribute it and/or modify
@@ -25,7 +25,7 @@ pool_dic = {}
 def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False):
     if not status:
         status={}
+
     db = get_db_only(db_name)
 
     if db_name in pool_dic:
@@ -35,7 +35,13 @@ def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False)
         import osv.osv
         pool = osv.osv.osv_pool()
         pool_dic[db_name] = pool
-        addons.load_modules(db, force_demo, status, update_module)
+
+        try:
+            addons.load_modules(db, force_demo, status, update_module)
+        except Exception:
+            del pool_dic[db_name]
+            raise
+
         cr = db.cursor()
         try:
             pool.init_set(cr, False)
@@ -43,16 +49,16 @@ def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False)
         finally:
             cr.close()
 
-        if not update_module:
-            import report
-            report.interface.register_all(db)
-            pool.get('ir.cron')._poolJobs(db.dbname)
+        import report
+        report.interface.register_all(db)
+        pool.get('ir.cron').restart(db.dbname)
     return db, pool
 
 
-def restart_pool(db_name, force_demo=False, update_module=False):
-    del pool_dic[db_name]
-    return get_db_and_pool(db_name, force_demo, update_module=update_module)
+def restart_pool(db_name, force_demo=False, status=None, update_module=False):
+    if db_name in pool_dic:
+        del pool_dic[db_name]
+    return get_db_and_pool(db_name, force_demo, status, update_module=update_module)
 
 
 def get_db_only(db_name):