From db035455a3ae4aa8cb2d50f6e17a7d900d3db0ac Mon Sep 17 00:00:00 2001 From: "Anup (OpenERP)" Date: Wed, 12 May 2010 16:12:49 +0530 Subject: [PATCH] [FIX] Export translations + Cache on translations + Resynchronization wizard Corrections bzr revid: ach@tinyerp.com-20100512104249-pqdbofr2xikw59l9 --- bin/addons/base/ir/ir_translation.py | 12 ++++++------ bin/osv/orm.py | 6 +++--- bin/tools/convert.py | 10 +++++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bin/addons/base/ir/ir_translation.py b/bin/addons/base/ir/ir_translation.py index 73536ac339f..8e575b6b242 100644 --- a/bin/addons/base/ir/ir_translation.py +++ b/bin/addons/base/ir/ir_translation.py @@ -150,8 +150,8 @@ class ir_translation(osv.osv): if not context: context = {} ids = super(ir_translation, self).create(cursor, user, vals, context=context) - for trans_obj in self.read(cursor, user, [ids], ['name','type','res_id'], context=context): - self._get_source.clear_cache(cursor.dbname, user, trans_obj['name'], trans_obj['type'], lang=context.get('lang','en_US')) + for trans_obj in self.read(cursor, user, [ids], ['name','type','res_id','src','lang'], context=context): + self._get_source.clear_cache(cursor.dbname, user, trans_obj['name'], trans_obj['type'], trans_obj['lang'], source=trans_obj['src']) self._get_ids.clear_cache(cursor.dbname, user, trans_obj['name'], trans_obj['type'], context.get('lang','en_US'), [trans_obj['res_id']]) return ids @@ -159,16 +159,16 @@ class ir_translation(osv.osv): if not context: context = {} result = super(ir_translation, self).write(cursor, user, ids, vals, context=context) - for trans_obj in self.read(cursor, user, ids, ['name','type','res_id'], context=context): - self._get_source.clear_cache(cursor.dbname, user, trans_obj['name'], trans_obj['type'], lang=context.get('lang','en_US')) + for trans_obj in self.read(cursor, user, ids, ['name','type','res_id','src','lang'], context=context): + self._get_source.clear_cache(cursor.dbname, user, trans_obj['name'], trans_obj['type'], trans_obj['lang'], source=trans_obj['src']) self._get_ids.clear_cache(cursor.dbname, user, trans_obj['name'], trans_obj['type'], context.get('lang','en_US'), [trans_obj['res_id']]) return result def unlink(self, cursor, user, ids, context=None): if not context: context = {} - for trans_obj in self.read(cursor, user, ids, ['name','type','res_id'], context=context): - self._get_source.clear_cache(cursor.dbname, user, trans_obj['name'], trans_obj['type'], lang=context.get('lang','en_US')) + for trans_obj in self.read(cursor, user, ids, ['name','type','res_id','src','lang'], context=context): + self._get_source.clear_cache(cursor.dbname, user, trans_obj['name'], trans_obj['type'], trans_obj['lang'], source=trans_obj['src']) self._get_ids.clear_cache(cursor.dbname, user, trans_obj['name'], trans_obj['type'], context.get('lang','en_US'), [trans_obj['res_id']]) result = super(ir_translation, self).unlink(cursor, user, ids, context=context) return result diff --git a/bin/osv/orm.py b/bin/osv/orm.py index 1ca5ca3ac2d..00c3f42ec4e 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -1092,8 +1092,7 @@ class orm_template(object): if getattr(self._columns[f], arg, None): res[f][arg] = getattr(self._columns[f], arg) - #TODO: optimize - res_trans = translation_obj._get_source(cr, user, self._name + ',' + f, 'field', context.get('lang', False) or 'en_US') + res_trans = translation_obj._get_source(cr, user, self._name + ',' + f, 'field', context.get('lang', False) or 'en_US', self._columns[f].string) if res_trans: res[f]['string'] = res_trans help_trans = translation_obj._get_source(cr, user, self._name + ',' + f, 'help', context.get('lang', False) or 'en_US') @@ -1708,7 +1707,8 @@ class orm_template(object): for lang in langs: for field in vals: if field in self._columns: - self.pool.get('ir.translation')._set_ids(cr, uid, self._name+','+field, 'field', lang, [0], vals[field]) + src = self._columns[field].string + self.pool.get('ir.translation')._set_ids(cr, uid, self._name+','+field, 'field', lang, [0], vals[field], src) for table in self._inherits: cols = intersect(self._inherit_fields.keys(), vals) if cols: diff --git a/bin/tools/convert.py b/bin/tools/convert.py index 2d760ef167f..4b996bc9c2f 100644 --- a/bin/tools/convert.py +++ b/bin/tools/convert.py @@ -29,7 +29,7 @@ import sys from datetime import datetime from lxml import etree - +import time import ir import misc import netsvc @@ -252,13 +252,13 @@ form: module.record_id""" % (xml_id,) if ids: self.pool.get(d_model).unlink(cr, self.uid, ids) self.pool.get('ir.model.data')._unlink(cr, self.uid, d_model, ids) - + def _remove_ir_values(self, cr, name, value, model): ir_value_ids = self.pool.get('ir.values').search(cr, self.uid, [('name','=',name),('value','=',value),('model','=',model)]) if ir_value_ids: self.pool.get('ir.values').unlink(cr, self.uid, ir_value_ids) self.pool.get('ir.model.data')._unlink(cr, self.uid, 'ir.values', ir_value_ids) - + return True def _tag_report(self, cr, rec, data_node=None): @@ -278,7 +278,7 @@ form: module.record_id""" % (xml_id,) res['header'] = eval(rec.get('header','False')) if rec.get('report_type'): res['report_type'] = rec.get('report_type') - + res['multi'] = rec.get('multi') and eval(rec.get('multi','False')) xml_id = rec.get('id','').encode('utf8') @@ -355,7 +355,7 @@ form: module.record_id""" % (xml_id,) # Special check for wizard having attribute menu=False on update value = 'ir.actions.wizard,'+str(id) self._remove_ir_values(cr, string, value, model) - + def _tag_url(self, cr, rec, data_node=None): url = rec.get("string",'').encode('utf8') target = rec.get("target",'').encode('utf8')