Revert "[IMP] translation: Added two columns to ir_translation to fix the res_ids after loading is done."

This reverts commit a78cd642cd956afe3f3cee54558b214549f0a9a5.

Conflicts:

	openerp/addons/base/ir/ir_translation.py
	openerp/tools/translate.py

bzr revid: xrg@linux.gr-20110608092941-f2ycamq0k52y4nc8
This commit is contained in:
P. Christeas
2011-06-08 12:29:41 +03:00
parent 01dcbe5313
commit 28e3960004
2 changed files with 12 additions and 27 deletions
+1 -4
View File
@@ -61,10 +61,6 @@ class ir_translation(osv.osv):
'type': fields.selection(TRANSLATION_TYPE, string='Type', size=16, select=True),
'src': fields.text('Source'),
'value': fields.text('Translation Value'),
# These two columns map to ir_model_data.module and ir_model_data.name.
# They are used to resolve the res_id above after loading is done.
'module': fields.char('Module', size=64, help='Maps to the ir_model_data for which this translation is provided.'),
'xml_id': fields.char('XML Id', size=128, help='Maps to the ir_model_data for which this translation is provided.'),
}
def _auto_init(self, cr, context={}):
@@ -92,6 +88,7 @@ class ir_translation(osv.osv):
cr.execute('CREATE INDEX ir_translation_ltn ON ir_translation (name, lang, type)')
cr.commit()
@tools.cache(skiparg=3, multi='ids')
def _get_ids(self, cr, uid, name, tt, lang, ids):
translations = dict.fromkeys(ids, False)
+11 -23
View File
@@ -909,13 +909,17 @@ def trans_load_data(cr, fileobj, fileformat, lang, lang_name=None, verbose=True,
try:
dic['res_id'] = dic['res_id'] and int(dic['res_id']) or 0
dic['module'] = False
dic['xml_id'] = False
except:
split_id = dic['res_id'].split('.', 1)
dic['module'] = split_id[0]
dic['xml_id'] = split_id[1]
dic['res_id'] = False
model_data_ids = model_data_obj.search(cr, uid, [
('model', '=', dic['name'].split(',')[0]),
('module', '=', dic['res_id'].split('.', 1)[0]),
('name', '=', dic['res_id'].split('.', 1)[1]),
])
if model_data_ids:
dic['res_id'] = model_data_obj.browse(cr, uid,
model_data_ids[0]).res_id
else:
dic['res_id'] = False
args = [
('lang', '=', lang),
@@ -924,11 +928,7 @@ def trans_load_data(cr, fileobj, fileformat, lang, lang_name=None, verbose=True,
('src', '=', dic['src']),
]
if dic['type'] == 'model':
if dic['res_id'] is False:
args.append(('module', '=', dic['module']))
args.append(('xml_id', '=', dic['xml_id']))
else:
args.append(('res_id', '=', dic['res_id']))
args.append(('res_id', '=', dic['res_id']))
ids = trans_obj.search(cr, uid, args)
if ids:
if context.get('overwrite') and dic['value']:
@@ -941,18 +941,6 @@ def trans_load_data(cr, fileobj, fileformat, lang, lang_name=None, verbose=True,
filename = '[lang: %s][format: %s]' % (iso_lang or 'new', fileformat)
logger.exception("couldn't read translation file %s", filename)
def trans_update_res_ids(cr):
cr.execute("""
UPDATE ir_translation
SET res_id = COALESCE ((SELECT ir_model_data.res_id
FROM ir_model_data
WHERE ir_translation.module = ir_model_data.module
AND ir_translation.xml_id = ir_model_data.name), 0)
WHERE ir_translation.module is not null
AND ir_translation.xml_id is not null
AND ir_translation.res_id = 0;
""")
def get_locales(lang=None):
if lang is None:
lang = locale.getdefaultlocale()[0]