[FIX] fields.reference: post-process reference fields to test if the referenced record exists.

bzr revid: vmt@openerp.com-20111005113434-itjuj0u3d6fhryn8
This commit is contained in:
Vo Minh Thu 2011-10-05 13:34:34 +02:00
commit 478854aac0
1 changed files with 13 additions and 0 deletions

View File

@ -156,9 +156,22 @@ class integer_big(_column):
class reference(_column):
_type = 'reference'
_classic_read = False # post-process to handle missing target
def __init__(self, string, selection, size, **args):
_column.__init__(self, string=string, size=size, selection=selection, **args)
def get(self, cr, obj, ids, name, uid=None, context=None, values=None):
result = {}
# copy initial values fetched previously.
for value in values:
if value[name]:
model, res_id = value[name].split(',')
if obj.pool.get(model).exists(cr, uid, [int(res_id)], context=context):
result[value['id']] = value[name]
else:
result[value['id']] = False
return result
class char(_column):
_type = 'char'