# values in the database, so we must ignore it : we generate a dummy leaf
self.__exp[i] = self.__DUMMY_LEAF
else:
- subexp = field.search(cr, uid, table, left, [self.__exp[i]])
+ subexp = field.search(cr, uid, table, left, [self.__exp[i]], context=context)
# we assume that the expression is valid
# we create a dummy leaf for forcing the parsing of the resulting expression
self.__exp[i] = '&'
# Applying recursivity on field(one2many)
if operator == 'child_of':
if isinstance(right, basestring):
- ids2 = [x[0] for x in field_obj.name_search(cr, uid, right, [], 'like', limit=None)]
+ ids2 = [x[0] for x in field_obj.name_search(cr, uid, right, [], 'like', context=context, limit=None)]
else:
ids2 = list(right)
if field._obj != working_table._name:
if right:
if isinstance(right, basestring):
- ids2 = [x[0] for x in field_obj.name_search(cr, uid, right, [], operator, limit=None)]
+ ids2 = [x[0] for x in field_obj.name_search(cr, uid, right, [], operator, context=context, limit=None)]
operator = 'in'
else:
if not isinstance(right,list):
#FIXME
if operator == 'child_of':
if isinstance(right, basestring):
- ids2 = [x[0] for x in field_obj.name_search(cr, uid, right, [], 'like', limit=None)]
+ ids2 = [x[0] for x in field_obj.name_search(cr, uid, right, [], 'like', context=context, limit=None)]
else:
ids2 = list(right)
call_null_m2m = True
if right:
if isinstance(right, basestring):
- res_ids = [x[0] for x in field_obj.name_search(cr, uid, right, [], operator)]
+ res_ids = [x[0] for x in field_obj.name_search(cr, uid, right, [], operator, context=context)]
operator = 'in'
else:
if not isinstance(right, list):
query = '(%s.%s in (%s))' % (table._table, left, right[0])
params = right[1]
elif operator in ['in', 'not in']:
- params = right[:]
+ params = right and right[:] or []
len_before = len(params)
for i in range(len_before)[::-1]:
if params[i] == False:
len_after = len(params)
check_nulls = len_after != len_before
query = '(1=0)'
-
+
if len_after:
if left == 'id':
instr = ','.join(['%s'] * len_after)
else:
instr = ','.join([table._columns[left]._symbol_set[0]] * len_after)
query = '(%s.%s %s (%s))' % (table._table, left, operator, instr)
-
+ else:
+ # the case for [field, 'in', []] or [left, 'not in', []]
+ if operator == 'in':
+ query = '(%s.%s IS NULL)' % (table._table, left)
+ else:
+ query = '(%s.%s IS NOT NULL)' % (table._table, left)
if check_nulls:
query = '(%s OR %s.%s IS NULL)' % (query, table._table, left)
else: