From 4bf43e21deade45f28bb827bf403d3a378f51409 Mon Sep 17 00:00:00 2001 From: William Braeckman Date: Fri, 6 May 2022 14:21:08 +0000 Subject: [PATCH] [FIX] account: fix terms in sitemap when it is not enabled The /terms page may be disabled/enabled in the company settings, however the page would always be present in the sitemap whether it is enabled or not. This commit adds a method that checks for this settings before adding it to the sitemap. TaskId-2820292 closes odoo/odoo#90930 X-original-commit: 729b99a789b52c09be0272cefa3bb0eaccd6803c Signed-off-by: Romain Derie (rde) --- addons/account/controllers/terms.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/account/controllers/terms.py b/addons/account/controllers/terms.py index b7e3b73cba8..f57296c0260 100644 --- a/addons/account/controllers/terms.py +++ b/addons/account/controllers/terms.py @@ -5,9 +5,17 @@ from odoo import http, _ from odoo.http import request +def sitemap_terms(env, rule, qs): + if qs and qs.lower() not in '/terms': + return + use_invoice_terms = env['ir.config_parameter'].sudo().get_param('account.use_invoice_terms') + if use_invoice_terms and env.company.terms_type == 'html': + yield {'loc': '/terms'} + + class TermsController(http.Controller): - @http.route('/terms', type='http', auth='public', website=True, sitemap=True) + @http.route('/terms', type='http', auth='public', website=True, sitemap=sitemap_terms) def terms_conditions(self, **kwargs): use_invoice_terms = request.env['ir.config_parameter'].sudo().get_param('account.use_invoice_terms') if not (use_invoice_terms and request.env.company.terms_type == 'html'):