summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorAnup (OpenERP) <ach@tinyerp.com>2010-08-20 15:50:12 +0530
committerAnup (OpenERP) <ach@tinyerp.com>2010-08-20 15:50:12 +0530
commitc9dcc96cd979cd9aa5f9d8a61e0f77de894bbde6 (patch)
tree1d63af4de9069bf071c26667665c804134c72299 /bin
parentadc6747716d3a770b29451131d4d48e91bdb1f46 (diff)
[FIX] Support for M2O with in,not in operators corrected
bzr revid: ach@tinyerp.com-20100820102012-36dtw2m3ujn27p7q
Diffstat (limited to 'bin')
-rw-r--r--bin/osv/expression.py26
1 files changed, 23 insertions, 3 deletions
diff --git a/bin/osv/expression.py b/bin/osv/expression.py
index 322ee3cd18d..f251f0bc444 100644
--- a/bin/osv/expression.py
+++ b/bin/osv/expression.py
@@ -115,6 +115,7 @@ class expression(object):
if self._is_operator(e) or e == self.__DUMMY_LEAF:
continue
left, operator, right = e
+ operator = operator.lower()
working_table = table
main_table = table
fargs = left.split('.', 1)
@@ -278,15 +279,34 @@ class expression(object):
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):
+ def _get_expression(field_obj,cr, uid, left, right, operator, context=None):
+ if context is None:
+ context = {}
c = context.copy()
c['active_test'] = False
+ dict_op = {'not in':'!=','in':'='}
+ if isinstance(right,tuple):
+ right = list(right)
+ if (not isinstance(right,list)) and operator in ['not in','in']:
+ operator = dict_op[operator]
res_ids = field_obj.name_search(cr, uid, right, [], operator, limit=None, context=c)
if not res_ids:
- self.__exp[i] = ('id','=',0)
+ return ('id','=',0)
else:
right = map(lambda x: x[0], res_ids)
- self.__exp[i] = (left, 'in', right)
+ return (left, 'in', right)
+
+ m2o_str = False
+ if isinstance(right, basestring): # and not isinstance(field, fields.related):
+ m2o_str = True
+ elif isinstance(right, list) or isinstance(right, tuple):
+ m2o_str = True
+ for ele in right:
+ if not isinstance(ele, basestring):
+ m2o_str = False
+ break
+ if m2o_str:
+ self.__exp[i] = _get_expression(field_obj,cr, uid, left, right, operator, context=context)
else:
# other field type
# add the time part to datetime field when it's not there: