[MERGE] [FIX] fields: avoid traceback when rendering reference field if link is broken (name_get returns no result)

bzr revid: mat@openerp.com-20131211165521-dxcjq7e35q8i0xs9
This commit is contained in:
Martin Trigaux
2013-12-11 17:55:21 +01:00
+2 -1
View File
@@ -204,7 +204,8 @@ class reference(_column):
model_name, res_id = value.split(',')
model = obj.pool.get(model_name)
if model and res_id:
return model.name_get(cr, uid, [int(res_id)], context=context)[0][1]
names = model.name_get(cr, uid, [int(res_id)], context=context)
return names[0][1] if names else False
return tools.ustr(value)
# takes a string (encoded in utf8) and returns a string (encoded in utf8)