[FIX] website: open the editor from a translated homepage
A bug currently prevents opening the editor from a translated version of the homepage, for example /nl_BE (it works for other paths though). Before this commit the url computed by _goToMasterPage was: /website/lang/default?r=/nl_BE?enable_editor=1&rde=2 which will first redirect to the default language and then again to the translated version. The bug was introduced by commit119d9437e0which chose an url without a trailing slash as the canonical one for the homepage. However, the bug can already be reproduced in 13.0 since commit269aa59411if the user manually navigates to /nl_BE instead of /nl_BE/. No flows are redirecting to the url without trailing slash in our codebase before 14.4, so the problem is rarely seen. When clicking on the "Edit in master" button, _goToMasterPage now correctly removes the language code and redirects to the master version, solving the problem. task-2622270 closes odoo/odoo#76837 X-original-commit: 141c15d5dae137df11a73146ff4c991add7a2ff3 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
This commit is contained in:
@@ -146,8 +146,11 @@ var TranslatePageMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({
|
||||
var current = document.createElement('a');
|
||||
current.href = window.location.toString();
|
||||
current.search += (current.search ? '&' : '?') + 'enable_editor=1';
|
||||
// we are in translate mode, the pathname starts with '/<url_code/'
|
||||
current.pathname = current.pathname.substr(Math.max(0, current.pathname.indexOf('/', 1)));
|
||||
// We are in translate mode, the pathname starts with '/<url_code>'. By
|
||||
// adding a trailing slash we can simply search for the first slash
|
||||
// after the language code to remove the language part.
|
||||
const startPath = (current.pathname + '/').indexOf('/', 1);
|
||||
current.pathname = current.pathname.substring(startPath);
|
||||
|
||||
var link = document.createElement('a');
|
||||
link.href = '/website/lang/default';
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/** @odoo-module **/
|
||||
|
||||
import tour from "web_tour.tour";
|
||||
|
||||
tour.register('edit_translated_page_redirect', {
|
||||
test: true,
|
||||
url: '/nl/contactus',
|
||||
}, [
|
||||
{
|
||||
content: 'click edit master',
|
||||
trigger: 'a[data-action="edit_master"]',
|
||||
},
|
||||
{
|
||||
content: 'check editor dashboard',
|
||||
trigger: '#oe_snippets',
|
||||
run: () => {
|
||||
// After checking the presence of the editor dashboard, we visit a
|
||||
// translated version of the homepage. The homepage is a special
|
||||
// case (there is no trailing slash), so we test it separately.
|
||||
location.href = '/nl';
|
||||
},
|
||||
},
|
||||
{
|
||||
content: 'click edit master',
|
||||
trigger: 'a[data-action="edit_master"]',
|
||||
},
|
||||
{
|
||||
content: 'check editor dashboard',
|
||||
trigger: '#oe_snippets',
|
||||
run: () => {},
|
||||
},
|
||||
]);
|
||||
@@ -216,3 +216,8 @@ class TestUi(odoo.tests.HttpCase):
|
||||
'mimetype': 'image/png',
|
||||
})
|
||||
self.start_tour('/', 'snippet_background_edition', login='admin')
|
||||
|
||||
def test_12_edit_translated_page_redirect(self):
|
||||
lang = self.env['res.lang']._activate_lang('nl_NL')
|
||||
self.env['website'].browse(1).write({'language_ids': [(4, lang.id, 0)]})
|
||||
self.start_tour("/nl/contactus", 'edit_translated_page_redirect', login='admin')
|
||||
|
||||
Reference in New Issue
Block a user