~ubuntu-branches/ubuntu/oneiric/openerp-server/oneiric

« back to all changes in this revision

Viewing changes to bin/osv/expression.py

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2011-01-01 09:45:38 UTC
  • mfrom: (19.2.1 sid)
  • Revision ID: james.westby@ubuntu.com-20110101094538-lg37tzn110haohp6
Tags: 5.0.15-2
* Removing README.source and headers in copyright file.
* Removing vcs fields.
* Updating year in copyright file.
* Orphaning package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
148
148
                    right1 = table.search(cr, uid, [(fargs[0],'in', right)], context=context)
149
149
                    self.__exp[i] = ('id', 'in', right1)                    
150
150
                
151
 
                continue
 
151
                if not isinstance(field,fields.property):
 
152
                    continue
152
153
 
153
154
            if field._properties and ((not field.store) or field._fnct_search):
154
155
 
285
286
                            context = {}
286
287
                        c = context.copy()
287
288
                        c['active_test'] = False
288
 
                        dict_op = {'not in':'!=','in':'='}
 
289
                        #Special treatment to ill-formed domains
 
290
                        operator = ( operator in ['<','>','<=','>='] ) and 'in' or operator
 
291
                        
 
292
                        dict_op = {'not in':'!=','in':'=','=':'in','!=':'not in','<>':'not in'}
289
293
                        if isinstance(right,tuple):
290
294
                            right = list(right)
291
295
                        if (not isinstance(right,list)) and operator in ['not in','in']:
292
296
                            operator = dict_op[operator]
293
 
                            
 
297
                        elif isinstance(right,list) and operator in ['<>','!=','=']: #for domain (FIELD,'=',['value1','value2'])
 
298
                            operator = dict_op[operator]
294
299
                        res_ids = field_obj.name_search(cr, uid, right, [], operator, limit=None, context=c)
295
300
                        if not res_ids:
296
301
                             return ('id','=',0)
299
304
                            return (left, 'in', right)
300
305
 
301
306
                    m2o_str = False
302
 
                    if isinstance(right, basestring): # and not isinstance(field, fields.related):
303
 
                        m2o_str = True
304
 
                    elif isinstance(right, list) or isinstance(right, tuple):
305
 
                        m2o_str = True
306
 
                        for ele in right:
307
 
                            if not isinstance(ele, basestring): 
308
 
                                m2o_str = False
309
 
                                break
 
307
                    if right:
 
308
                        if isinstance(right, basestring): # and not isinstance(field, fields.related):
 
309
                            m2o_str = True
 
310
                        elif isinstance(right,(list,tuple)):
 
311
                            m2o_str = True
 
312
                            for ele in right:
 
313
                                if not isinstance(ele, basestring): 
 
314
                                    m2o_str = False
 
315
                                    break
 
316
                    else:
 
317
                        new_op = '='
 
318
                        if operator in  ['not like','not ilike','not in','<>','!=']:
 
319
                            new_op = '!='
 
320
                        #Is it ok to put 'left' and not 'id' ?
 
321
                        self.__exp[i] = (left,new_op,False)
310
322
 
311
323
                    if m2o_str:
312
324
                        self.__exp[i] = _get_expression(field_obj,cr, uid, left, right, operator, context=context)