Files
odoo_source/addons/web_editor/models/ir_http.py
T
Martin Trigaux 8b8815f44c [FIX] http_routing: translate without website
web (tagged with `openerp-web`) translations are loaded in the backend, in
`odoo.addons.web.controllers.main.WebClient.translation(mods=None, lang=None)`
method (through `/web/webclient/translations` controller).

In website, the controller `/website/translations` is called used, fetching
the translations from modules with the (fragile) clause `name ilike 'website'`

This commit fixes two bugs:

1. Install `website_sale`, activate discussion on products
  -> the chatter is not translated as the portal translations not loaded in the
     `/website/translations` controller

2. Install `helpdesk` but not `website`, go to portal view of a ticket
   -> the heldesk chatter is not translated as the `/website/translations`
      controller is not called (only provided by the website module)

This patch implements a modular approach to translate the web resources of the
right modules only.

The controller /website/translation is moved to http_routing and each module
override the new _get_translation_frontend_modules_domain method to adds its
translatable module

Closes #23618
Fixes #23610
2018-04-11 16:55:14 +02:00

28 lines
1022 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import models
from odoo.http import request
from odoo.osv import expression
class IrHttp(models.AbstractModel):
_inherit = 'ir.http'
@classmethod
def _dispatch(cls):
context = dict(request.context)
if 'editable' in request.httprequest.args and 'editable' not in context:
context['editable'] = True
if 'edit_translations' in request.httprequest.args and 'edit_translations' not in context:
context['edit_translations'] = True
if context.get('edit_translations') and 'translatable' not in context:
context['translatable'] = True
request.context = context
return super(IrHttp, cls)._dispatch()
@classmethod
def _get_translation_frontend_modules_domain(cls):
domain = super(IrHttp, cls)._get_translation_frontend_modules_domain()
return expression.OR([domain, [('name', '=', 'web_editor')]])