From b7a2cc13bad36e08e1e1f56391bc95a6ab623c9b Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Tue, 16 Sep 2014 15:41:37 +0200 Subject: [PATCH] [FIX] ir.translation: translated terms within view definitions were not loaded The changes for QWeb template translation have introduced res_id values in PO comments for all `#: view:` terms, as the real database id needs to be resolved when loading them. For non-QWeb views this is not necessary and actually caused the terms to be dropped when the res_id could not be resolved. Rather than having a different PO comment format for QWeb and non-QWeb views, we can extend the QWeb hack to force the res_id to 0 for non-QWeb views. Fixes issue #1755 --- openerp/addons/base/ir/ir_translation.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/openerp/addons/base/ir/ir_translation.py b/openerp/addons/base/ir/ir_translation.py index c970475916f..8e20a837045 100644 --- a/openerp/addons/base/ir/ir_translation.py +++ b/openerp/addons/base/ir/ir_translation.py @@ -79,9 +79,13 @@ class ir_translation_import_cursor(object): """ params = dict(trans_dict, state="translated" if trans_dict['value'] else "to_translate") - # ugly hack for QWeb views - pending refactoring of translations in master - if params['imd_model'] == 'website' and params['type'] == 'view': - params['imd_model'] = "ir.ui.view" + if params['type'] == 'view': + # ugly hack for QWeb views - pending refactoring of translations in master + if params['imd_model'] == 'website': + params['imd_model'] = "ir.ui.view" + # non-QWeb views do not need a matching res_id -> force to 0 to avoid dropping them + elif params['res_id'] is None: + params['res_id'] = 0 self._cr.execute("""INSERT INTO %s (name, lang, res_id, src, type, imd_model, module, imd_name, value, state, comments) VALUES (%%(name)s, %%(lang)s, %%(res_id)s, %%(src)s, %%(type)s, %%(imd_model)s, %%(module)s,