[FIX] ir.translation: translated terms within view definitions were not loaded
[odoo/odoo.git] / openerp / addons / base / ir / ir_translation.py
index c970475..8e20a83 100644 (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,