[IMP] fields.reference: two loops one loop.

bzr revid: vmt@openerp.com-20111005105103-cutnuvfkgsjej3vc
This commit is contained in:
Vo Minh Thu 2011-10-05 12:51:03 +02:00
parent 2fd484263a
commit 7ccc7f388f
1 changed files with 7 additions and 8 deletions

View File

@ -164,14 +164,13 @@ class reference(_column):
def get(self, cr, obj, ids, name, uid=None, context=None, values=None): def get(self, cr, obj, ids, name, uid=None, context=None, values=None):
result = {} result = {}
# copy initial values fetched previously. # copy initial values fetched previously.
for row in values: for value in values:
result[row['id']] = row[name] if value[name]:
# verify target object exists model, res_id = value[name].split(',')
for id, value in result.iteritems(): if obj.pool.get(model).exists(cr, uid, [int(res_id)], context=context):
if value: result[value['id']] = value[name]
model, res_id = value.split(',') else:
if not obj.pool.get(model).exists(cr, uid, [int(res_id)], context=context): result[value['id']] = False
result[id] = False
return result return result
class char(_column): class char(_column):