← Back to team overview

credativ team mailing list archive

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

 

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

Requested reviews:
  Holger Brunn (Therp) (hbrunn): code review

For more details, see:
https://code.launchpad.net/~therp-nl/openupgrade-server/7.0-fix_forced_deps/+merge/176709
-- 
https://code.launchpad.net/~therp-nl/openupgrade-server/7.0-fix_forced_deps/+merge/176709
Your team OpenUpgrade Committers is subscribed to branch lp:openupgrade-server.
=== modified file 'openerp/openupgrade/doc/source/intro.rst'
--- openerp/openupgrade/doc/source/intro.rst	2012-11-24 22:22:00 +0000
+++ openerp/openupgrade/doc/source/intro.rst	2013-08-02 12:37:24 +0000
@@ -53,3 +53,23 @@
    against it to test how the migrated data behaves under the new version. 
    Remember that the OpenUpgrade version of the source code is only intended to 
    perform the migration, not run the OpenERP server.
+
+Configuration options
+=====================
+
+OpenUpgrade allows for the following configuration options. Add these options
+to a separate stanza in the server configuration file under a header 
+*[openupgrade]*
+
+* *autoinstall* - A dictionary with module name keys and lists of module names
+  as values. If a key module is installed on your database, the modules from
+  the value (and their dependencies) are selected for installation as well.
+
+* *forced_deps* - A dictionary with module name keys and lists of module names
+  as values. If a key module is installed on your database, the modules from
+  the value will be treated as a module dependency. With this directive, you
+  can manipulate the order in which the modules are migrated. If the modules
+  from the value are not already installed on your database, they will be
+  selected for installation (as will their dependencies). Be careful not to
+  introduce a circular dependency using this directive.
+

=== modified file 'openerp/openupgrade/openupgrade_loading.py'
--- openerp/openupgrade/openupgrade_loading.py	2013-07-24 12:20:41 +0000
+++ openerp/openupgrade/openupgrade_loading.py	2013-08-02 12:37:24 +0000
@@ -21,10 +21,15 @@
 
 import logging
 import types
+<<<<<<< TREE
 from openerp import SUPERUSER_ID
+=======
+from openerp import release
+>>>>>>> MERGE-SOURCE
 from openerp.osv.orm import TransientModel
 from openerp.osv import fields
 from openerp.openupgrade.openupgrade import table_exists
+from openerp.tools import config, safe_eval
 
 # A collection of functions used in 
 # openerp/modules/loading.py
@@ -36,10 +41,31 @@
     Select (new) dependencies from the modules in the list
     so that we can inject them into the graph at upgrade
     time. Used in the modified OpenUpgrade Server,
-    not to be used in migration scripts
+    not to be called from migration scripts
+
+    Also take the OpenUpgrade configuration directives 'forced_deps'
+    and 'autoinstall' into account. From any additional modules
+    that these directives can add, the dependencies are added as
+    well (but these directives are not checked for the occurrence
+    of any of the dependencies).
     """
     if not module_list:
         return module_list
+
+    forced_deps = safe_eval.safe_eval(
+        config.get_misc(
+            'openupgrade', 'forced_deps_' + release.version, 
+            config.get_misc('openupgrade', 'forced_deps', '{}')))
+
+    autoinstall = safe_eval.safe_eval(
+        config.get_misc(
+            'openupgrade', 'autoinstall_' + release.version, 
+            config.get_misc('openupgrade', 'autoinstall', '{}')))
+
+    for module in list(module_list):
+        module_list += forced_deps.get(module, [])
+        module_list += autoinstall.get(module, [])
+
     cr.execute("""
         SELECT ir_module_module_dependency.name
         FROM
@@ -49,8 +75,10 @@
             module_id = ir_module_module.id
             AND ir_module_module.name in %s
         """, (tuple(module_list),))
-    dependencies = [x[0] for x in cr.fetchall()]
-    return list(set(module_list + dependencies))
+
+    return list(set(
+            module_list + [x[0] for x in cr.fetchall()]
+            ))
 
 def log_model(model, local_registry):
     """


Follow ups