[FIX]base, ir_translation: in _get_src, if model or record id does not exist anymore, do not apptempt to read it

bzr revid: dle@openerp.com-20130924124654-9lz76t6hx0cmxnx5
This commit is contained in:
Denis Ledoux 2013-09-24 14:46:54 +02:00
parent 89848bce01
commit 447dec696b
1 changed files with 8 additions and 6 deletions

View File

@ -161,18 +161,20 @@ class ir_translation(osv.osv):
''' '''
if context is None: if context is None:
context = {} context = {}
res = {} res = dict.fromkeys(ids, False)
for record in self.browse(cr, uid, ids, context=context): for record in self.browse(cr, uid, ids, context=context):
if record.type != 'model': if record.type != 'model':
res[record.id] = record.src res[record.id] = record.src
else: else:
model_name, field = record.name.split(',') model_name, field = record.name.split(',')
model = self.pool.get(model_name) model = self.pool.get(model_name)
#We need to take the context without the language information, because we want to read the if model and model.exists(cr, uid, record.res_id, context=context):
#value store in db and not on the one associate with current language. #We need to take the context without the language information, because we want to read the
context_wo_lang = context.copy() #value store in db and not on the one associate with current language.
context_wo_lang.pop('lang', None) context_wo_lang = context.copy()
res[record.id] = model.read(cr, uid, record.res_id, [field], context=context_wo_lang)[field] context_wo_lang.pop('lang', None)
result = model.read(cr, uid, record.res_id, [field], context=context_wo_lang)
res[record.id] = result and result[field] or False
return res return res
def _set_src(self, cr, uid, id, name, value, args, context=None): def _set_src(self, cr, uid, id, name, value, args, context=None):