summaryrefslogtreecommitdiff
path: root/addons/website/models/ir_qweb.py
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2019-03-25 12:05:24 +0000
committerNicolas Lempereur <nle@odoo.com>2019-04-02 14:45:24 +0000
commit8557bcfa302de7aca4b5dadb35841cd52f9ebfff (patch)
treef05d8ab6540354fa8bc6b054c77b6aca81b62205 /addons/website/models/ir_qweb.py
parentf1744a31a1fa3494345f9502bfd6cb5b8aa95ffa (diff)
[FIX] website: language prefixed URL on website bis
Reintroduces 5324284f5 that was reverted because in the case of an URL like /payment_stripe/static/src/js/stripe.js directly inside a QWeb template, we would possibly get: /fr_FR/payment_stripe/static/src/js/stripe.js Which is not accepted by werkzeug SharedDataMiddleware we use to serve static data in /{module_name}/static/ directories. Added test without changeset failed with: - test_process_att_no_request_lang: <AssertionError> line: self._test_att('/en_US/', {'href': '/'}) wrong result: {'href': '/en_US/'} - test_process_att_with_request_lang: <AssertionError> line: self._test_att('/', {'href': '/fr_FR/'}) wrong result: {'href': '/'} - test_process_att_matching_cdn_and_lang: <AssertionError> line: self._test_att('/en_US/a', {'href': 'http://test.cdn/a'}) wrong result: {'href': 'http://test.cdn/en_US/a'} - test_process_att_no_route: <AssertionError> line: self._test_att('/my-page', {'href': '/fr_FR/my-page'}) wrong result: {'href': '/my-page'} - test_process_att_url_crap: <IndexError: list index out of range> line: request.httprequest.app._log_call[-1], opw-1922051 closes #32095 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Diffstat (limited to 'addons/website/models/ir_qweb.py')
-rw-r--r--addons/website/models/ir_qweb.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/addons/website/models/ir_qweb.py b/addons/website/models/ir_qweb.py
index 0f73bc469f5..0c7900e9a47 100644
--- a/addons/website/models/ir_qweb.py
+++ b/addons/website/models/ir_qweb.py
@@ -4,6 +4,7 @@ import re
from collections import OrderedDict
from odoo import models
+from odoo.addons.http_routing.models.ir_http import url_for
from odoo.http import request
@@ -37,10 +38,16 @@ class QWeb(models.AbstractModel):
if not website and options.get('website_id'):
website = self.env['website'].browse(options['website_id'])
- if not website or not website.cdn_activated:
+ if not website:
return atts
name = self.URL_ATTRS.get(tagName)
+ if request and name and name in atts:
+ atts[name] = url_for(atts[name])
+
+ if not website.cdn_activated:
+ return atts
+
if name and name in atts:
atts = OrderedDict(atts)
atts[name] = website.get_cdn_url(atts[name])