From f5724590ce894a156c7e5fb63648f1b355d22f58 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Thu, 5 Feb 2009 11:30:42 +0100 Subject: [PATCH] [FIX] modules that cannot be loaded are marked as uninstallable bzr revid: christophe@tinyerp.com-20090205103042-hkqsip3d4mgf7smh --- bin/addons/__init__.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/bin/addons/__init__.py b/bin/addons/__init__.py index fcc60ca1809..57d5742431e 100644 --- a/bin/addons/__init__.py +++ b/bin/addons/__init__.py @@ -273,26 +273,23 @@ def get_modules(): return list(set(listdir(ad) + listdir(_ad))) -def create_graph(module_list, force=None): +def create_graph(cr, module_list, force=None): graph = Graph() - upgrade_graph(graph, module_list, force) + upgrade_graph(graph, cr, module_list, force) return graph -def upgrade_graph(graph, module_list, force=None): +def upgrade_graph(graph, cr, module_list, force=None): if force is None: force = [] packages = [] len_graph = len(graph) for module in module_list: - try: - mod_path = get_module_path(module) - if not mod_path: - continue - except IOError: - continue + mod_path = get_module_path(module) terp_file = get_module_resource(module, '__terp__.py') - if not terp_file: + if not mod_path or not terp_file: + cr.execute("update ir_module_module set state=%s where name=%s", ('uninstallable', module)) continue + if os.path.isfile(terp_file) or zipfile.is_zipfile(mod_path+'.zip'): try: info = eval(tools.file_open(terp_file).read()) @@ -662,7 +659,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False): try: report = tools.assertion_report() STATES_TO_LOAD = ['installed', 'to upgrade'] - graph = create_graph(['base'], force) + graph = create_graph(cr, ['base'], force) has_updates = False if update_module: has_updates = load_module_graph(cr, graph, status, perform_checks=False, report=report) @@ -698,7 +695,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False): if not module_list: break - new_modules_in_graph = upgrade_graph(graph, module_list, force) + new_modules_in_graph = upgrade_graph(graph, cr, module_list, force) if new_modules_in_graph == 0: # nothing to load break