"""
def _is_operator(self, element):
- return isinstance(element, str) \
- and element in ['&', '|', '!']
+ return isinstance(element, (str, unicode)) and element in ['&', '|', '!']
def _is_leaf(self, element, internal=False):
OPS = ('=', '!=', '<>', '<=', '<', '>', '>=', '=like', 'like', 'not like', 'ilike', 'not ilike', 'in', 'not in', 'child_of')
if not self.__exp:
return self
- def _rec_get(ids, table, parent, left='id', prefix=''):
+ def _rec_get(ids, table, parent=None, left='id', prefix=''):
if table._parent_store and (not table.pool._init):
# TODO: Improve where joins are implemented for many with '.', replace by:
# doms += ['&',(prefix+'.parent_left','<',o.parent_right),(prefix+'.parent_left','>=',o.parent_left)]
return []
ids2 = table.search(cr, uid, [(parent, 'in', ids)], context=context)
return ids + rg(ids2, table, parent)
- return [(left, 'in', rg(ids, table, parent))]
+ return [(left, 'in', rg(ids, table, parent or table._parent_name))]
self.__main_table = table
field = working_table._columns.get(fargs[0], False)
if not field:
if left == 'id' and operator == 'child_of':
- dom = _rec_get(right, working_table, working_table._parent_name)
+ dom = _rec_get(right, working_table)
self.__exp = self.__exp[:i] + dom + self.__exp[i+1:]
continue
return ids
return self.__execute_recursive_in(cr, field._id1, field._rel, field._id2, ids)
- dom = _rec_get(ids2, field_obj, working_table._parent_name)
+ dom = _rec_get(ids2, field_obj)
ids2 = field_obj.search(cr, uid, dom, context=context)
self.__exp[i] = ('id', 'in', _rec_convert(ids2))
else:
self.__operator = 'in'
if field._obj != working_table._name:
- dom = _rec_get(ids2, field_obj, working_table._parent_name, left=left, prefix=field._obj)
+ dom = _rec_get(ids2, field_obj, left=left, prefix=field._obj)
else:
- dom = _rec_get(ids2, working_table, left)
+ dom = _rec_get(ids2, working_table, parent=left)
self.__exp = self.__exp[:i] + dom + self.__exp[i+1:]
else:
if isinstance(right, basestring): # and not isinstance(field, fields.related):
- res_ids = field_obj.name_search(cr, uid, right, [], operator, limit=None)
+ c = context.copy()
+ c['active_test'] = False
+ res_ids = field_obj.name_search(cr, uid, right, [], operator, limit=None, context=c)
right = map(lambda x: x[0], res_ids)
self.__exp[i] = (left, 'in', right)
else:
if len_after:
if left == 'id':
- instr = ','.join(['%s'] * len_after)
+ 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)
query = '(%s OR %s IS NULL)' % (query, left)
else:
params = []
- if (((right == False) and (type(right)==bool)) or (right is None)) and (operator == '='):
- query = '%s IS NULL' % left
+
+ if right == False and (leaf[0] in table._columns) and table._columns[leaf[0]]._type=="boolean" and (operator == '='):
+ query = '(%s.%s IS NULL or %s.%s = false )' % (table._table, left,table._table, left)
+ elif (((right == False) and (type(right)==bool)) or (right is None)) and (operator == '='):
+ query = '%s.%s IS NULL ' % (table._table, left)
+ elif right == False and (leaf[0] in table._columns) and table._columns[leaf[0]]._type=="boolean" and (operator in ['<>', '!=']):
+ query = '(%s.%s IS NOT NULL and %s.%s != false)' % (table._table, left,table._table, left)
elif (((right == False) and (type(right)==bool)) or right is None) and (operator in ['<>', '!=']):
- query = '%s IS NOT NULL' % left
+ query = '%s.%s IS NOT NULL' % (table._table, left)
else:
if left == 'id':
query = '%s.id %s %%s' % (table._table, operator)