[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) <qsm@odoo.com>
Signed-off-by: Benoit Socias (bso) <bso@odoo.com>
This commit is contained in:
Benoit Socias
2022-10-18 11:21:15 +02:00
committed by qsm-odoo
parent d15ff0818d
commit 93d63a7f28
@@ -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`);
}
}