← Back to team overview

openerp-expert-framework team mailing list archive

Fix module unloading

 

I don't know how many of you have tried to unload a module lately. It seems I 
was completely unable to do so, until this patch was applied. 


From beda3e684823373e12e2f0fb311aecf5a632e2d3 Mon Sep 17 00:00:00 2001
From: P. Christeas <p_christ@xxxxxx>
Date: Wed, 27 Jan 2010 22:29:27 +0200
Subject: [PATCH] [Fix] Unloading of modules: don't try to unlink itselves

Each module has one (at least) reference to itself 'ir.module.module' in
ir.model.data, which holds the metainformation. When removing all module's
data, don't try to destroy the module itself at that time.
---
 bin/addons/__init__.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/bin/addons/__init__.py b/bin/addons/__init__.py
index 782f977..624c91f 100644
--- a/bin/addons/__init__.py
+++ b/bin/addons/__init__.py
@@ -772,7 +772,9 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
         if update_module:
             cr.execute("SELECT id, name FROM ir_module_module WHERE state=%s", ('to remove',))
             for mod_id, mod_name in cr.fetchall():
-                cr.execute('SELECT model, res_id FROM ir_model_data WHERE noupdate=%s AND module=%s ORDER BY id DESC', (False, mod_name,))
+                cr.execute('SELECT model, res_id FROM ir_model_data '
+                        'WHERE noupdate=%s AND module=%s AND model <> \'ir.module.module\' '
+                        'ORDER BY id DESC', (False, mod_name,))
                 for rmod, rid in cr.fetchall():
                     uid = 1
                     rmod_module= pool.get(rmod)
-- 
1.6.4.4


Follow ups