Files
odoo_source/addons/account/controllers/terms.py
T
William Braeckman 4bf43e21de [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) <rde@odoo.com>
2022-05-09 19:56:53 +02:00

30 lines
1.2 KiB
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
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=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'):
return request.render('http_routing.http_error', {
'status_code': _('Oops'),
'status_message': _("""The requested page is invalid, or doesn't exist anymore.""")})
values = {
'use_invoice_terms': use_invoice_terms,
'company': request.env.company
}
return request.render("account.account_terms_conditions_page", values)