[FIX] Expression : Making search easier for 'child_of'- Recursivity on field used as a Left operand

bzr revid: jvo@tinyerp.com-20091123122736-591bz55oke4ot5mj
This commit is contained in:
ACH(OpenERP) 2009-11-23 17:57:36 +05:30 committed by Jay (Open ERP)
parent b4fdda88f2
commit 360d52e45b
1 changed files with 41 additions and 22 deletions

View File

@ -141,6 +141,12 @@ class expression(object):
if field._type == 'many2one':
right = field_obj.search(cr, uid, [(fargs[1], operator, right)], context=context)
self.__exp[i] = (fargs[0], 'in', right)
# Making search easier when there is a left operand as field.o2m or field.m2m
if field._type in ['many2many','one2many']:
right = field_obj.search(cr, uid, [(fargs[1], operator, right)], context=context)
right1 = table.search(cr, uid, [(fargs[0],'in', right)], context=context)
self.__exp[i] = ('id', 'in', right1)
continue
if field._properties:
@ -163,6 +169,19 @@ class expression(object):
elif field._type == 'one2many':
# 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)]
else:
ids2 = list(right)
if field._obj != working_table._name:
dom = _rec_get(ids2, field_obj, left=left, prefix=field._obj)
else:
dom = _rec_get(ids2, working_table, parent=left)
self.__exp = self.__exp[:i] + dom + self.__exp[i+1:]
else:
call_null = True
if right: