From 048e6e91b73e2fc470865b36e5cada4b2548d35b Mon Sep 17 00:00:00 2001 From: Mantavya Gajjar Date: Wed, 9 Apr 2008 09:52:31 +0000 Subject: [PATCH] Add 'not in' operator functionality in where_calc function. bzr revid: mga@tinyerp.com-c5695f14aeca4a3ba171f7c8007f8c83e1b13930 --- bin/osv/orm.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/bin/osv/orm.py b/bin/osv/orm.py index a92605cbe9a..bf58b908886 100644 --- a/bin/osv/orm.py +++ b/bin/osv/orm.py @@ -1952,6 +1952,23 @@ class orm(object): if x[1] == 'inselect': qu1.append('(%s.%s in (%s))' % (table._table, x[0], x[2][0])) qu2 += x[2][1] + if x[1]=='not in': + if len(x[2])>0: + todel = [] + for xitem in range(len(x[2])): + if x[2][xitem]==False and isinstance(x[2][xitem],bool): + todel.append(xitem) + for xitem in todel[::-1]: + del x[2][xitem] + if x[0]=='id': + qu1.append('(%s.id not in (%s))' % (table._table, ','.join(['%d'] * len(x[2])),)) + else: + qu1.append('(%s.%s not in (%s))' % (table._table, x[0], ','.join([table._columns[x[0]]._symbol_set[0]]*len(x[2])))) + if todel: + qu1[-1] = '('+qu1[-1]+' or '+x[0]+' is null)' + qu2+=x[2] + else: + qu1.append(' (1=0)') elif x[1] != 'in': #FIXME: this replace all (..., '=', False) values with 'is null' and this is # not what we want for real boolean fields. The problem is, we can't change it