summaryrefslogtreecommitdiff
path: root/addons/http_routing/models
diff options
context:
space:
mode:
authorXavier-Do <xdo@odoo.com>2019-10-15 14:28:33 +0000
committerfw-bot <otis@odoo.com>2019-10-17 17:10:06 +0000
commitd65fcfecb6424d1e99df56611e374f8a97682c3d (patch)
tree9d2f831e0c3e59018e8a808c9b083c1488f435eb /addons/http_routing/models
parented1236275ffae625716af5e0dca730c0c26117cd (diff)
[FIX] web: avoid expensive 404 during js tests
A 404 will take 3 to 5 seconds to be resolved and execute +- 1900 query, to return a rendered page which is quite expensive, especially when multiple missing images are rendered in a view. Catching static route and marking them as not frontend will help to avoid to handle miss on static resources. In this case server returns a standard 404. This commit also fix a iframe src in order to avoid a 404 on /web/(test )/report/html/some_report (thx to aab-odoo) X-original-commit: 818d0cb59fbae78d0edf06318082981f318e4db7
Diffstat (limited to 'addons/http_routing/models')
-rw-r--r--addons/http_routing/models/ir_http.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/addons/http_routing/models/ir_http.py b/addons/http_routing/models/ir_http.py
index 571f47918a0..fd7fde19d75 100644
--- a/addons/http_routing/models/ir_http.py
+++ b/addons/http_routing/models/ir_http.py
@@ -427,8 +427,12 @@ class IrHttp(models.AbstractModel):
request.is_frontend = func.routing.get('website', False)
except werkzeug.exceptions.NotFound as e:
# either we have a language prefixed route, either a real 404
- # in all cases, website processes them
- request.is_frontend = True
+ # in all cases, website processes them exept if second element is static
+ # Checking static will avoid to generate an expensive 404 web page since
+ # most of the time the browser is loading and inexisting assets or image. A standard 404 is enough.
+ # Earlier check would be difficult since we don't want to break data modules
+ path_components = request.httprequest.path.split('/')
+ request.is_frontend = len(path_components) < 3 or path_components[2] != 'static' or not '.' in path_components[-1]
routing_error = e
request.is_frontend_multilang = not func or (func and request.is_frontend and func.routing.get('multilang', func.routing['type'] == 'http'))