From 795b2bdcae1afb92baa100a366e957661979316e Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Mon, 17 Jan 2011 10:41:08 +0200 Subject: [PATCH] expression: fix function.search() when it does not restrict Triggered by [Bug 702340] When we try to search a composite expression like: [( 'ourfoo.subfoo', '=' , True) ] .. where subfoo is a function field of the model ofourfoo field, the framework will call subfoo.search([('subfoo','=',True)]). The latter shall return a domain expression that will restrict the search on 'ourfoo'. When the returned expression is empty, meaning "match all", the algebra on the parent expression would come up with an invalid [..., '&', ( 1, '=', 1) ] sequence. bzr revid: p_christ@hol.gr-20110117084108-vt1qe72lhw8ldxqm --- bin/osv/expression.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bin/osv/expression.py b/bin/osv/expression.py index 7608e963e7a..f83c044c2e4 100644 --- a/bin/osv/expression.py +++ b/bin/osv/expression.py @@ -167,12 +167,15 @@ class expression(object): self.__exp[i] = self.__DUMMY_LEAF else: subexp = field.search(cr, uid, table, left, [self.__exp[i]], context=context) - # we assume that the expression is valid - # we create a dummy leaf for forcing the parsing of the resulting expression - self.__exp[i] = '&' - self.__exp.insert(i + 1, self.__DUMMY_LEAF) - for j, se in enumerate(subexp): - self.__exp.insert(i + 2 + j, se) + if not subexp: + self.__exp[i] = self.__DUMMY_LEAF + else: + # we assume that the expression is valid + # we create a dummy leaf for forcing the parsing of the resulting expression + self.__exp[i] = '&' + self.__exp.insert(i + 1, self.__DUMMY_LEAF) + for j, se in enumerate(subexp): + self.__exp.insert(i + 2 + j, se) # else, the value of the field is store in the database, so we search on it elif field._type == 'one2many':