[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
This commit is contained in:
Olivier Dony 2014-09-16 15:41:37 +02:00
parent 2e0189770b
commit b7a2cc13ba
1 changed files with 7 additions and 3 deletions

View File

@ -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,