[FIX] Translation issue with cache: it needed to restart server,SOLVED

lp bug: https://launchpad.net/bugs/399208 fixed

bzr revid: jvo@tinyerp.com-20090903124928-mbzr7ekxoo4sba49
This commit is contained in:
ACH,Jay 2009-09-03 18:19:28 +05:30 committed by Jay (Open ERP)
parent 460f3102bc
commit 02fd0eb506
1 changed files with 27 additions and 0 deletions

View File

@ -143,6 +143,33 @@ class ir_translation(osv.osv):
res = cr.fetchone()
trad = res and res[0] or ''
return trad
def create(self, cursor, user, vals, context=None):
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'))
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
def write(self, cursor, user, ids, vals, context=None):
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'))
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'))
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
ir_translation()