Files
odoo_source/addons/http_routing/controllers/main.py
T
Martin Geubelle c54caca54d [IMP] website: Cache translations forever
Generate a unique URL for translations and cache them forever in the
browser. This reduces the number of requests, in exchange for computing
the hash of the translations when the session object is added to the page
2019-05-22 07:52:07 +00:00

24 lines
871 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import odoo
from odoo import http
from odoo.http import request
from odoo.osv import expression
from odoo.addons.web.controllers.main import WebClient, Home
class Routing(Home):
@http.route('/website/translations/<string:unique>', type='http', auth="public", website=True)
def get_website_translations(self, unique, lang, mods=None):
Modules = request.env['ir.module.module'].sudo()
IrHttp = request.env['ir.http'].sudo()
domain = IrHttp._get_translation_frontend_modules_domain()
modules = Modules.search(
expression.AND([domain, [('state', '=', 'installed')]])
).mapped('name')
if mods:
modules += mods
return WebClient().translations(unique, mods=','.join(modules), lang=lang)