← Back to team overview

credativ team mailing list archive

[Merge] lp:~therp-nl/openupgrade-server/7.0-lp1279549-select_autoinstallable_modules into lp:openupgrade-server

 

Stefan Rijnhart (Therp) has proposed merging lp:~therp-nl/openupgrade-server/7.0-lp1279549-select_autoinstallable_modules into lp:openupgrade-server.

Commit message:
[FIX] Select new autoinstallable modules at upgrade time

Requested reviews:
  OpenUpgrade Committers (openupgrade-committers)
Related bugs:
  Bug #1279549 in OpenUpgrade Server: "[7.0] new auto-installable modules are not installed automatically"
  https://bugs.launchpad.net/openupgrade-server/+bug/1279549

For more details, see:
https://code.launchpad.net/~therp-nl/openupgrade-server/7.0-lp1279549-select_autoinstallable_modules/+merge/211001
-- 
https://code.launchpad.net/~therp-nl/openupgrade-server/7.0-lp1279549-select_autoinstallable_modules/+merge/211001
Your team OpenUpgrade Committers is requested to review the proposed merge of lp:~therp-nl/openupgrade-server/7.0-lp1279549-select_autoinstallable_modules into lp:openupgrade-server.
=== modified file 'openerp/openupgrade/openupgrade_loading.py'
--- openerp/openupgrade/openupgrade_loading.py	2013-09-13 19:40:16 +0000
+++ openerp/openupgrade/openupgrade_loading.py	2014-03-14 09:11:54 +0000
@@ -19,6 +19,7 @@
 #
 ##############################################################################
 
+import logging
 import types
 from openerp import release
 from openerp.osv.orm import TransientModel
@@ -29,6 +30,8 @@
 # A collection of functions used in 
 # openerp/modules/loading.py
 
+logger = logging.getLogger('OpenUpgrade')
+
 def add_module_dependencies(cr, module_list):
     """
     Select (new) dependencies from the modules in the list
@@ -69,9 +72,32 @@
             AND ir_module_module.name in %s
         """, (tuple(module_list),))
 
-    return list(set(
-            module_list + [x[0] for x in cr.fetchall()]
-            ))
+    module_list = list(set(
+        module_list + [row[0] for row in cr.fetchall()]))
+
+    # Select auto_install modules of which all dependencies
+    # are fulfilled based on the modules we know are to be
+    # installed
+    cr.execute("""
+        SELECT name from ir_module_module WHERE state IN %s
+        """, (('installed', 'to install', 'to upgrade'),))
+    modules = list(set(module_list + [row[0] for row in cr.fetchall()]))
+    cr.execute("""
+        SELECT name from ir_module_module m
+        WHERE auto_install IS TRUE
+            AND state = 'uninstalled'
+            AND NOT EXISTS(
+                SELECT id FROM ir_module_module_dependency d
+                WHERE d.module_id = m.id
+                AND name NOT IN %s)
+         """, (tuple(modules),))
+    auto_modules = [row[0] for row in cr.fetchall()]
+    if auto_modules:
+        logger.info(
+            "Selecting autoinstallable modules %s", ','.join(auto_modules))
+        module_list += auto_modules
+
+    return module_list
 
 def log_model(model, local_registry):
     """


References