[IMP] improved code.
bzr revid: tpa@tinyerp.com-20120713055330-avz6ebzuqvcpxdd5
This commit is contained in:
@@ -594,9 +594,9 @@ class module(osv.osv):
|
||||
self.write(cr, uid, [mod_browse.id], {'category_id': p_id})
|
||||
|
||||
def update_translations(self, cr, uid, ids, filter_lang=None, context=None):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
if context is None:
|
||||
context = {}
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
if not filter_lang:
|
||||
lang_obj = pool.get('res.lang')
|
||||
lang_ids = lang_obj.search(cr, uid, [('translatable', '=', True)])
|
||||
@@ -607,8 +607,7 @@ class module(osv.osv):
|
||||
for mod in self.browse(cr, uid, ids):
|
||||
if mod.state != 'installed':
|
||||
continue
|
||||
traslation_obj = pool.get('ir.translation')
|
||||
traslation_obj.load(cr, [mod.name], filter_lang, context=context)
|
||||
pool.get('ir.translation').load(cr, [mod.name], filter_lang, context=context)
|
||||
|
||||
def check(self, cr, uid, ids, context=None):
|
||||
for mod in self.browse(cr, uid, ids, context=context):
|
||||
|
||||
@@ -784,9 +784,7 @@ class translation(netsvc.ExportService):
|
||||
|
||||
def exp_load(self, db, modules, langs, flag=None, context=None):
|
||||
cr = pooler.get_db(db).cursor()
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
traslation_obj = pool.get('ir.translation')
|
||||
translated_data = traslation_obj.load(cr, modules, langs, flag, context=context)
|
||||
translated_data = pooler.get_pool(db).get('ir.translation').load(cr, modules, langs, flag, context=context)
|
||||
cr.commit()
|
||||
cr.close()
|
||||
return translated_data
|
||||
|
||||
@@ -846,20 +846,18 @@ def trans_generate(lang, modules, cr):
|
||||
def trans_load(cr, filename, lang, verbose=True, flag=None, module_name=None, context=None):
|
||||
try:
|
||||
fileobj = misc.file_open(filename)
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
traslation_obj = pool.get('ir.translation')
|
||||
traslation_obj = pooler.get_pool(cr.dbname).get('ir.translation')
|
||||
_logger.info("loading %s", filename)
|
||||
transl = []
|
||||
if flag == 'web':
|
||||
transl = []
|
||||
trans_ids = traslation_obj.search(cr, 1, [('module','=', module_name),('lang','=',lang)])
|
||||
for trans in traslation_obj.browse(cr, 1, trans_ids, context=context):
|
||||
transl.append({'id': trans.src, 'string': trans.value})
|
||||
return transl
|
||||
else:
|
||||
fileformat = os.path.splitext(filename)[-1][1:].lower()
|
||||
trans_load_data(cr, fileobj, fileformat, lang, verbose=verbose, module_name=module_name, context=context)
|
||||
fileobj.close()
|
||||
return []
|
||||
return transl
|
||||
except IOError:
|
||||
if verbose:
|
||||
_logger.error("couldn't read translation file %s", filename)
|
||||
|
||||
Reference in New Issue
Block a user