[FIX] add get method in refrence field and check if refrence id not exists then return false.

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

bzr revid: ysa@tinyerp.com-20110624084656-c2jd3xskk10fwt35
This commit is contained in:
Yogesh (OpenERP) 2011-06-24 14:16:56 +05:30
parent 47dba87bcd
commit b505076369
1 changed files with 14 additions and 0 deletions

View File

@ -148,9 +148,23 @@ 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 row in values:
result[row['id']] = row[name]
# verify target object exists
for id, value in result.iteritems():
if value:
model, res_id = value.split(',')
if not obj.pool.get(model).exists(cr, uid, [int(res_id)], context=context):
result[id] = False
return result
class char(_column):
_type = 'char'