Files
project_v19/custom_template_khmer/controllers/main.py
T
2026-07-01 14:41:49 +07:00

46 lines
1.8 KiB
Python

# custom_template_khmer/controllers/main.py
from odoo import http
from odoo.http import request
import logging
_logger = logging.getLogger(__name__)
class CustomThemeController(http.Controller):
# @http.route('/custom_template_khmer/fonts', type='http', auth='public')
# def get_font(self):
# """Serve custom font file"""
# try:
# config = request.env['custom.theme.config'].sudo().search([], limit=1)
# if config and config.font_file:
# return request.make_response(
# config.font_file,
# headers=[
# ('Content-Type', 'font/ttf'),
# ('Content-Disposition', f'inline; filename={config.font_name}.ttf'),
# ('Cache-Control', 'public, max-age=31536000')
# ]
# )
# except Exception as e:
# _logger.error(f"Error serving font: {str(e)}")
#
# return request.make_response("", headers=[('Content-Type', 'text/plain')])
@http.route('/custom_template_khmer/menu_image', type='http', auth='public')
def get_menu_image(self):
"""Serve menu background image"""
try:
config = request.env['custom.theme.config'].sudo().search([], limit=1)
if config and config.menu_bg_image:
return request.make_response(
config.menu_bg_image,
headers=[
('Content-Type', 'image/png'),
('Cache-Control', 'public, max-age=31536000')
]
)
except Exception as e:
_logger.error(f"Error serving menu image: {str(e)}")
return request.make_response("", headers=[('Content-Type', 'text/plain')])