[FIX] website, website_report: backwards compatibility with outdated templates

* Complements commits a696913364 and
21d4b3fda9 by adding the missing `data-lang`
attribute also in the report layout (in saas-6 a single QWeb
template is used for language links in both reports and website
layouts).

* Fix the "Edit Master" link to work also for outdated templates
where the data-lang attribute is dynamically set to 'default',
and thus cannot be used as URL prefix -> use /website/lang
controller to switch lang instead.
This commit is contained in:
Olivier Dony 2015-05-18 19:24:19 +02:00
parent 235cd2d015
commit d5aa22ea5f
2 changed files with 5 additions and 2 deletions

View File

@ -60,9 +60,11 @@
ev.preventDefault();
var link = $('.js_language_selector a[data-default-lang]')[0];
if (link) {
link.pathname = $(link).data('lang') + link.pathname;
link.search += (link.search ? '&' : '?') + 'enable_editor=1';
window.location = link.attributes.href.value;
var url = link.pathname + link.search + window.location.hash;
link.pathname = '/website/lang/default';
link.search = '?' + $.param({r: url});
window.location = link.href;
}
},
translate: function () {

View File

@ -23,6 +23,7 @@
<ul class="list-inline js_language_selector mt16" t-if="(request and request.website_multilang and len(languages) &gt; 1) or (website and editable)">
<li t-foreach="languages" t-as="lg">
<a t-att-href="url_for(request.httprequest.path + '?' + keep_query(), lang=lg[0])"
t-att-data-lang="lg[0]"
t-att-data-default-lang="editable and 'true' if website and lg[0] == website.default_lang_code else None">
<t t-esc="lg[1].split('/').pop()"/>
</a>