[FIX] Expression : Corrected operator handling for domains containing Many2one fields
lp bug: https://launchpad.net/bugs/651999 fixed bzr revid: jvo@tinyerp.com-20101006180432-mkaqstcuvakci7hq
This commit is contained in:
parent
9f2d1a15a0
commit
40ed04d094
|
@ -284,11 +284,16 @@ class expression(object):
|
||||||
context = {}
|
context = {}
|
||||||
c = context.copy()
|
c = context.copy()
|
||||||
c['active_test'] = False
|
c['active_test'] = False
|
||||||
dict_op = {'not in':'!=','in':'='}
|
#Special treatment to ill-formed domains
|
||||||
|
operator = ( operator in ['<','>','<=','>='] ) and 'in' or operator
|
||||||
|
|
||||||
|
dict_op = {'not in':'!=','in':'=','=':'in','!=':'not in','<>':'not in'}
|
||||||
if isinstance(right,tuple):
|
if isinstance(right,tuple):
|
||||||
right = list(right)
|
right = list(right)
|
||||||
if (not isinstance(right,list)) and operator in ['not in','in']:
|
if (not isinstance(right,list)) and operator in ['not in','in']:
|
||||||
operator = dict_op[operator]
|
operator = dict_op[operator]
|
||||||
|
elif isinstance(right,list) and operator in ['<>','!=','=']: #for domain (FIELD,'=',['value1','value2'])
|
||||||
|
operator = dict_op[operator]
|
||||||
res_ids = field_obj.name_search(cr, uid, right, [], operator, limit=None, context=c)
|
res_ids = field_obj.name_search(cr, uid, right, [], operator, limit=None, context=c)
|
||||||
if not res_ids:
|
if not res_ids:
|
||||||
return ('id','=',0)
|
return ('id','=',0)
|
||||||
|
@ -297,14 +302,22 @@ class expression(object):
|
||||||
return (left, 'in', right)
|
return (left, 'in', right)
|
||||||
|
|
||||||
m2o_str = False
|
m2o_str = False
|
||||||
if isinstance(right, basestring): # and not isinstance(field, fields.related):
|
if right:
|
||||||
m2o_str = True
|
if isinstance(right, basestring): # and not isinstance(field, fields.related):
|
||||||
elif isinstance(right, list) or isinstance(right, tuple):
|
m2o_str = True
|
||||||
m2o_str = True
|
elif isinstance(right,(list,tuple)):
|
||||||
for ele in right:
|
m2o_str = True
|
||||||
if not isinstance(ele, basestring):
|
for ele in right:
|
||||||
m2o_str = False
|
if not isinstance(ele, basestring):
|
||||||
break
|
m2o_str = False
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
new_op = '='
|
||||||
|
if operator in ['not like','not ilike','not in','<>','!=']:
|
||||||
|
new_op = '!='
|
||||||
|
#Is it ok to put 'left' and not 'id' ?
|
||||||
|
self.__exp[i] = (left,new_op,False)
|
||||||
|
|
||||||
if m2o_str:
|
if m2o_str:
|
||||||
self.__exp[i] = _get_expression(field_obj,cr, uid, left, right, operator, context=context)
|
self.__exp[i] = _get_expression(field_obj,cr, uid, left, right, operator, context=context)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue