From 256eae55b494238dc9481ac404d0a9d6e5f22465 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 8 Aug 2012 18:59:04 +0200 Subject: [PATCH] [FIX] db: module auto-install should work recursively during db bootstrap too bzr revid: odo@openerp.com-20120808165904-hyyxn3djm75od67b --- openerp/modules/db.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/openerp/modules/db.py b/openerp/modules/db.py index 7490631a3b9..1bf7b5237f1 100644 --- a/openerp/modules/db.py +++ b/openerp/modules/db.py @@ -68,10 +68,7 @@ def initialize(cr): category_id = create_categories(cr, categories) if info['installable']: - if info['auto_install'] and not info['depends']: - state = 'to install' - else: - state = 'uninstalled' + state = 'uninstalled' else: state = 'uninstallable' @@ -95,7 +92,19 @@ def initialize(cr): for d in dependencies: cr.execute('INSERT INTO ir_module_module_dependency \ (module_id,name) VALUES (%s, %s)', (id, d)) - cr.commit() + + # Install recursively all auto-installing modules + while True: + cr.execute("""SELECT m.name FROM ir_module_module m WHERE m.auto_install AND state != 'to install' + AND NOT EXISTS ( + SELECT 1 FROM ir_module_module_dependency d JOIN ir_module_module mdep ON (d.name = mdep.name) + WHERE d.module_id = m.id AND mdep.state != 'to install' + )""") + to_auto_install = [x[0] for x in cr.fetchall()] + if not to_auto_install: break + cr.execute("""UPDATE ir_module_module SET state='to install' WHERE name in %s""", (tuple(to_auto_install),)) + + cr.commit() def create_categories(cr, categories): """ Create the ir_module_category entries for some categories.