[FIX] Export translations + Cache on translations + Resynchronization wizard Corrections

bzr revid: ach@tinyerp.com-20100512104249-pqdbofr2xikw59l9
This commit is contained in:
Anup (OpenERP) 2010-05-12 16:12:49 +05:30
parent 8f81995ec8
commit db035455a3
3 changed files with 14 additions and 14 deletions

View File

@ -150,8 +150,8 @@ class ir_translation(osv.osv):
if not context: if not context:
context = {} context = {}
ids = super(ir_translation, self).create(cursor, user, vals, 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): 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'], lang=context.get('lang','en_US')) 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']]) 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 return ids
@ -159,16 +159,16 @@ class ir_translation(osv.osv):
if not context: if not context:
context = {} context = {}
result = super(ir_translation, self).write(cursor, user, ids, vals, 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): 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'], lang=context.get('lang','en_US')) 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']]) 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 return result
def unlink(self, cursor, user, ids, context=None): def unlink(self, cursor, user, ids, context=None):
if not context: if not context:
context = {} context = {}
for trans_obj in self.read(cursor, user, ids, ['name','type','res_id'], context=context): 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'], lang=context.get('lang','en_US')) 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']]) 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) result = super(ir_translation, self).unlink(cursor, user, ids, context=context)
return result return result

View File

@ -1092,8 +1092,7 @@ class orm_template(object):
if getattr(self._columns[f], arg, None): if getattr(self._columns[f], arg, None):
res[f][arg] = getattr(self._columns[f], arg) 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', self._columns[f].string)
res_trans = translation_obj._get_source(cr, user, self._name + ',' + f, 'field', context.get('lang', False) or 'en_US')
if res_trans: if res_trans:
res[f]['string'] = 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') 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 lang in langs:
for field in vals: for field in vals:
if field in self._columns: 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: for table in self._inherits:
cols = intersect(self._inherit_fields.keys(), vals) cols = intersect(self._inherit_fields.keys(), vals)
if cols: if cols:

View File

@ -29,7 +29,7 @@ import sys
from datetime import datetime from datetime import datetime
from lxml import etree from lxml import etree
import time
import ir import ir
import misc import misc
import netsvc import netsvc
@ -252,13 +252,13 @@ form: module.record_id""" % (xml_id,)
if ids: if ids:
self.pool.get(d_model).unlink(cr, self.uid, ids) self.pool.get(d_model).unlink(cr, self.uid, ids)
self.pool.get('ir.model.data')._unlink(cr, self.uid, d_model, ids) self.pool.get('ir.model.data')._unlink(cr, self.uid, d_model, ids)
def _remove_ir_values(self, cr, name, value, model): 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)]) ir_value_ids = self.pool.get('ir.values').search(cr, self.uid, [('name','=',name),('value','=',value),('model','=',model)])
if ir_value_ids: if ir_value_ids:
self.pool.get('ir.values').unlink(cr, self.uid, 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) self.pool.get('ir.model.data')._unlink(cr, self.uid, 'ir.values', ir_value_ids)
return True return True
def _tag_report(self, cr, rec, data_node=None): 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')) res['header'] = eval(rec.get('header','False'))
if rec.get('report_type'): if rec.get('report_type'):
res['report_type'] = rec.get('report_type') res['report_type'] = rec.get('report_type')
res['multi'] = rec.get('multi') and eval(rec.get('multi','False')) res['multi'] = rec.get('multi') and eval(rec.get('multi','False'))
xml_id = rec.get('id','').encode('utf8') 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 # Special check for wizard having attribute menu=False on update
value = 'ir.actions.wizard,'+str(id) value = 'ir.actions.wizard,'+str(id)
self._remove_ir_values(cr, string, value, model) self._remove_ir_values(cr, string, value, model)
def _tag_url(self, cr, rec, data_node=None): def _tag_url(self, cr, rec, data_node=None):
url = rec.get("string",'').encode('utf8') url = rec.get("string",'').encode('utf8')
target = rec.get("target",'').encode('utf8') target = rec.get("target",'').encode('utf8')