[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.
This commit is contained in:
Jérome Maes
2016-08-04 12:02:13 +02:00
parent 73749499f0
commit 7c20b4785b
2 changed files with 8 additions and 4 deletions
+5 -1
View File
@@ -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
+3 -3
View File
@@ -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: