From c3ccfbe98deb92c451eb6323ef4951fd430f56f7 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Tue, 25 Apr 2023 16:49:51 +0000 Subject: [PATCH] [FIX] website: don't show website info page in sitemap if disabled This commit is simply conditionning the presence of the /website/info page in the sitemap so it's removed from it if you disable/remove the website info view. It will help SEO wise to not have error page in it. Also note that it has always been in sitemap, even if marked excplicitely since [1]. [1]: https://github.com/odoo/odoo/commit/e19227d3ba9c9296bfc0c221ac70a863a571b9a6#diff-d41b2dc5ff6fd6a303373f86e1af97d055db315ccc431749b4ffac1488dea119L200 opw-3255831 closes odoo/odoo#121226 X-original-commit: b4ae4a0f8b592a07537f051d4a8a4152ac7df9c6 Signed-off-by: Quentin Smetz (qsm) Signed-off-by: Romain Derie (rde) --- addons/website/controllers/main.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index 7cf4d5fd1f8..a0dd7b5a765 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -296,7 +296,19 @@ class Website(Home): response.headers['Cache-Control'] = 'public, max-age=%s' % http.STATIC_CACHE_LONG return response - @http.route('/website/info', type='http', auth="public", website=True, sitemap=True) + def sitemap_website_info(env, rule, qs): + website = env['website'].get_current_website() + if not ( + website.viewref('website.website_info', False).active + and website.viewref('website.show_website_info', False).active + ): + # avoid 404 or blank page in sitemap + return False + + if not qs or qs.lower() in '/website/info': + yield {'loc': '/website/info'} + + @http.route('/website/info', type='http', auth="public", website=True, sitemap=sitemap_website_info) def website_info(self, **kwargs): Module = request.env['ir.module.module'].sudo() apps = Module.search([('state', '=', 'installed'), ('application', '=', True)])