diff options
| author | Goffin Simon <simon.goffin@outlook.com> | 2015-02-13 13:30:53 +0100 |
|---|---|---|
| committer | Goffin Simon <sig@odoo.com> | 2015-02-24 14:01:34 +0100 |
| commit | cbb51610ee1506e67f5aaab703130ff8a2d824b6 (patch) | |
| tree | bf7a1330c7c8dffb3e6fc61c4680dbf45a9cf15c /addons/website/controllers/main.py | |
| parent | 46186f54eb92601f6187c78e87c05d8e8ec07a4a (diff) | |
[FIX] ir.ui.view: qweb translations: allow looking up translation in parent template
- Translations lookup normally uses the namespace of the current
QWeb template, after merging all inherited views.
But when a QWeb template is "cloned" by a child view using
inheritance with `primary` mode, the translations are more
likely to exist for the original (parent) template, and would not
be found when using only the "child" namespace.
This patch adds support for looking up each translation
also in the parent namespace in this case, if none was found
for the child template in the first place.
- ir.translation's _get_source() now supports a list of res_id
to search for, in addition to a single res_id
- Also moved the logic of routes /website/customize_template_get
and /website/get_view_translations to the ir.ui.view model where
it belongs.
opw: 615241
Closes #5325
Diffstat (limited to 'addons/website/controllers/main.py')
| -rw-r--r-- | addons/website/controllers/main.py | 48 |
1 files changed, 5 insertions, 43 deletions
diff --git a/addons/website/controllers/main.py b/addons/website/controllers/main.py index 5c808c47b4e..6a907512c17 100644 --- a/addons/website/controllers/main.py +++ b/addons/website/controllers/main.py @@ -227,54 +227,16 @@ class Website(openerp.addons.web.controllers.main.Home): @http.route('/website/customize_template_get', type='json', auth='user', website=True) def customize_template_get(self, xml_id, full=False): - """ Lists the templates customizing ``xml_id``. By default, only - returns optional templates (which can be toggled on and off), if - ``full=True`` returns all templates customizing ``xml_id`` - """ - imd = request.registry['ir.model.data'] - view_model, view_theme_id = imd.get_object_reference( - request.cr, request.uid, 'website', 'theme') + return request.registry["ir.ui.view"].customize_template_get( + request.cr, request.uid, xml_id, full=full, context=request.context) - user = request.registry['res.users']\ - .browse(request.cr, request.uid, request.uid, request.context) - user_groups = set(user.groups_id) - - views = request.registry["ir.ui.view"]\ - ._views_get(request.cr, request.uid, xml_id, context=dict(request.context or {}, active_test=False)) - done = set() - result = [] - for v in views: - if not user_groups.issuperset(v.groups_id): - continue - if full or (v.customize_show and v.inherit_id.id != view_theme_id): - if v.inherit_id not in done: - result.append({ - 'name': v.inherit_id.name, - 'id': v.id, - 'xml_id': v.xml_id, - 'inherit_id': v.inherit_id.id, - 'header': True, - 'active': False - }) - done.add(v.inherit_id) - result.append({ - 'name': v.name, - 'id': v.id, - 'xml_id': v.xml_id, - 'inherit_id': v.inherit_id.id, - 'header': False, - 'active': v.active, - }) - return result @http.route('/website/get_view_translations', type='json', auth='public', website=True) def get_view_translations(self, xml_id, lang=None): lang = lang or request.context.get('lang') - views = self.customize_template_get(xml_id, full=True) - views_ids = [view.get('id') for view in views if view.get('active')] - domain = [('type', '=', 'view'), ('res_id', 'in', views_ids), ('lang', '=', lang)] - irt = request.registry.get('ir.translation') - return irt.search_read(request.cr, request.uid, domain, ['id', 'res_id', 'value','state','gengo_translation'], context=request.context) + return request.registry["ir.ui.view"].get_view_translations( + request.cr, request.uid, xml_id, lang=lang, context=request.context) + @http.route('/website/set_translations', type='json', auth='public', website=True) def set_translations(self, data, lang): |
