From b6ed34e134f868d7ccdfcb436592e0cc343fa3b5 Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Wed, 30 Oct 2019 12:10:37 +0000 Subject: [PATCH] [FIX] ir_http: declare class attributes _routing_map and _rewrite_len Actually, the two class attributes are only set when calling the routing_map method. As a consequence, when the url_for function in the http_routing module tries to access the _rewrite_len attribute, it may crashe. This problem arrise in the TestQwebProcessAtt from the website module when the test is run alone. It was hidden on the runbot because some missconfigured HttpCase tests were run at_install before TestQwebProcessAtt. In that particular case, the routing_map method is called and sets the attribute. With this commit, the _routing_map and _rewrite_len class attributes are set on the class at class declaration time. --- odoo/addons/base/models/ir_http.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/odoo/addons/base/models/ir_http.py b/odoo/addons/base/models/ir_http.py index 5418789b716..70730917ae2 100644 --- a/odoo/addons/base/models/ir_http.py +++ b/odoo/addons/base/models/ir_http.py @@ -82,6 +82,9 @@ class IrHttp(models.AbstractModel): # Routing map #------------------------------------------------------ + _routing_map = {} + _rewrite_len = {} + @classmethod def _get_converters(cls): return {'model': ModelConverter, 'models': ModelsConverter, 'int': SignedIntConverter} @@ -250,9 +253,6 @@ class IrHttp(models.AbstractModel): @classmethod def routing_map(cls, key=None): - if not hasattr(cls, '_routing_map'): - cls._routing_map = {} - cls._rewrite_len = {} if key not in cls._routing_map: _logger.info("Generating routing map for key %s" % str(key)) installed = request.registry._init_modules | set(odoo.conf.server_wide_modules)