[FIX] correct graph loading when updating database or installing new module from command line

lp bug: https://launchpad.net/bugs/304807 fixed

bzr revid: nel@silver-20081210141128-oaknnb0rzj68htio
This commit is contained in:
Najlaa 2008-12-10 15:11:28 +01:00
parent 02663d9780
commit 5a836ab275
2 changed files with 36 additions and 12 deletions

View File

@ -527,28 +527,48 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
if force_demo:
force.append('demo')
pool = pooler.get_pool(cr.dbname)
report = tools.assertion_report()
if update_module:
for module in tools.config['init']:
basegraph = create_graph(['base'], force)
load_module_graph(cr, basegraph, status, report=report)
modobj = pool.get('ir.module.module')
modobj.update_list(cr, 1)
if tools.config['init']:
ids = modobj.search(cr, 1, ['&', ('state', '=', 'uninstalled'), ('name', 'in', tools.config['init'])])
if ids:
#modobj.write(cr, ids, {'state': 'to install'})
modobj.button_install(cr, 1, ids)
ids = modobj.search(cr, 1, ['&', '!', ('name', '=', 'base'), ('state', 'in', ('installed', 'to upgrade'))])
if ids:
modobj.button_upgrade(cr, 1, ids)
"""
for module in modobj.browse(cr, uid, modobj.search(crtools.config['init']:
cr.execute('update ir_module_module set state=%s where state=%s and name=%s', ('to install', 'uninstalled', module))
cr.commit()
register_class('base')
pool.instanciate('base', cr)
modobj = pool.get('ir.module.module')
modobj.update_list(cr, 1)
mids = modobj.search(cr, 1, [('state','in',('installed','to install'))])
for m in modobj.browse(cr, 1, mids):
for dep in m.dependencies_id:
if dep.state=='uninstalled':
modobj.button_install(cr, 1, [m.id])
,
mids = modobj.search(cr, 1, [('state','in',('installed','to install'))])
for m in modobj.browse(cr, 1, mids):
for dep in m.dependencies_id:
if dep.state=='uninstalled':
modobj.button_install(cr, 1, [m.id])
#"""
cr.execute("select name from ir_module_module where state in ('installed', 'to install', 'to upgrade','to remove')")
else:
cr.execute("select name from ir_module_module where state in ('installed', 'to upgrade', 'to remove')")
module_list = [name for (name,) in cr.fetchall()]
graph = create_graph(module_list, force)
report = tools.assertion_report()
base = graph['base']
for kind in ('init', 'demo', 'update'):
if hasattr(base, kind):
delattr(base, kind)
load_module_graph(cr, graph, status, report=report)
if report.get_report():
logger.notifyChannel('init', netsvc.LOG_INFO, 'assert: %s' % report)

View File

@ -261,6 +261,7 @@ class module(osv.osv):
def button_upgrade(self, cr, uid, ids, context=None):
depobj = self.pool.get('ir.module.module.dependency')
todo = self.browse(cr, uid, ids, context=context)
to_install = set()
i = 0
while i<len(todo):
mod = todo[i]
@ -272,7 +273,10 @@ class module(osv.osv):
for dep in depobj.browse(cr, uid, iids, context=context):
if dep.module_id.state=='installed':
todo.append(dep.module_id)
elif dep.module_id.state == 'uninstalled':
to_install.add(dep.module_id.id)
self.write(cr,uid, map(lambda x: x.id, todo), {'state':'to upgrade'}, context=context)
self.button_install(cr, uid, list(to_install))
return True
def button_upgrade_cancel(self, cr, uid, ids, context={}):