[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:
parent
47dba87bcd
commit
b505076369
|
@ -148,9 +148,23 @@ class integer_big(_column):
|
||||||
|
|
||||||
class reference(_column):
|
class reference(_column):
|
||||||
_type = 'reference'
|
_type = 'reference'
|
||||||
|
_classic_read = False # post-process to handle missing target
|
||||||
|
|
||||||
def __init__(self, string, selection, size, **args):
|
def __init__(self, string, selection, size, **args):
|
||||||
_column.__init__(self, string=string, size=size, selection=selection, **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):
|
class char(_column):
|
||||||
_type = 'char'
|
_type = 'char'
|
||||||
|
|
Loading…
Reference in New Issue