From 7c20b4785bef5bf2fd84b429d42a2f3425801410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Maes?= Date: Fri, 15 Jul 2016 10:29:51 +0200 Subject: [PATCH] [FIX] ir_http: setting the routing_map on the class The routing map should be static. Being calling from the old api (with registry) there was no problem. But since the new API works with instance, a new instance of the ir.http model will recreate its own routing map. This should have been avoid during migration to new api of ir.http . Anyway, this prevent many mistake for the website migration. --- openerp/addons/base/ir/ir_http.py | 6 +++++- openerp/modules/loading.py | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/openerp/addons/base/ir/ir_http.py b/openerp/addons/base/ir/ir_http.py index 6e6cb250312..81500d3f7b8 100644 --- a/openerp/addons/base/ir/ir_http.py +++ b/openerp/addons/base/ir/ir_http.py @@ -205,7 +205,11 @@ class IrHttp(models.AbstractModel): if tools.config['test_enable']: installed.add(odoo.modules.module.current_test) mods = [''] + odoo.conf.server_wide_modules + sorted(installed) - self._routing_map = http.routing_map(mods, False, converters=self._get_converters()) + # Note : when routing map is generated, we put it on the class `type(self)` + # to make it available for all instance. Since `env` create an new instance + # of the model, each instance will regenared its own routing map and thus + # regenerate its EndPoint. The routing map should be static. + type(self)._routing_map = http.routing_map(mods, False, converters=self._get_converters()) return self._routing_map diff --git a/openerp/modules/loading.py b/openerp/modules/loading.py index 5824993aeb5..05b68e9ef1d 100644 --- a/openerp/modules/loading.py +++ b/openerp/modules/loading.py @@ -52,7 +52,7 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, skip_modules= cr.commit() else: cr.rollback() - # avoid keeping stale xml_id, etc. in cache + # avoid keeping stale xml_id, etc. in cache openerp.modules.registry.RegistryManager.clear_caches(cr.dbname) @@ -186,7 +186,7 @@ def load_module_graph(cr, graph, status=None, perform_checks=True, skip_modules= ir_http = registry['ir.http'] if hasattr(ir_http, '_routing_map'): # Force routing map to be rebuilt between each module test suite - del(ir_http._routing_map) + del(type(ir_http)._routing_map) report.record_result(openerp.modules.module.run_unit_tests(module_name, cr.dbname)) processed_modules.append(package.name) @@ -268,7 +268,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False): if 'base' in tools.config['update'] or 'all' in tools.config['update']: cr.execute("update ir_module_module set state=%s where name=%s and state=%s", ('to upgrade', 'base', 'installed')) - # STEP 1: LOAD BASE (must be done before module dependencies can be computed for later steps) + # STEP 1: LOAD BASE (must be done before module dependencies can be computed for later steps) graph = openerp.modules.graph.Graph() graph.add_module(cr, 'base', force) if not graph: