From 93d63a7f28505881dc583b4aad0ef233e8f0dba8 Mon Sep 17 00:00:00 2001 From: Benoit Socias Date: Tue, 27 Sep 2022 13:30:17 +0000 Subject: [PATCH] [FIX] website: return to the root page after install from 404 page This commit removes the path part of the reloaded page after a module is installed from the website editor so that it lands on the root page of the website, when the current page is a 404. Steps to reproduce: - Access `/@/a`, an undefined page. - Edit. - Discard. - +New. - Install Blog. => Reloaded `/@/a` but without its assets generated. closes odoo/odoo#103345 X-original-commit: 886900c33d18f647016e596ba41c193f5fcf8a43 Signed-off-by: Quentin Smetz (qsm) Signed-off-by: Benoit Socias (bso) --- addons/website/static/src/systray_items/new_content.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/website/static/src/systray_items/new_content.js b/addons/website/static/src/systray_items/new_content.js index efebce9df6b..dd0066e8665 100644 --- a/addons/website/static/src/systray_items/new_content.js +++ b/addons/website/static/src/systray_items/new_content.js @@ -170,10 +170,14 @@ export class NewContentModal extends Component { if (redirectUrl) { window.location.replace(redirectUrl); } else { - const { id, metadata: { path } } = this.website.currentWebsite; + const { id, metadata: { path, viewXmlid } } = this.website.currentWebsite; + const url = new URL(path); + if (viewXmlid === 'website.page_404') { + url.pathname = ''; + } // A reload is needed after installing a new module, to instantiate // a NewContentModal with patches from the installed module. - window.location.replace(`/web#action=website.website_preview&website_id=${id}&path=${encodeURIComponent(path)}&display_new_content=true`); + window.location.replace(`/web#action=website.website_preview&website_id=${id}&path=${encodeURIComponent(url.toString())}&display_new_content=true`); } }