diff --git a/openerp/addons/base/test/test_osv_expression.yml b/openerp/addons/base/test/test_osv_expression.yml index 97ab6c9e83c..3e9a0f6fb3e 100644 --- a/openerp/addons/base/test/test_osv_expression.yml +++ b/openerp/addons/base/test/test_osv_expression.yml @@ -466,3 +466,9 @@ assert len(all_ids) == 1, "Must match India only, got %r"%all_ids all_ids = self.search(cr, uid, [('name', '=ilike', 'z%')]) assert len(all_ids) == 3, "Must match only countries with names starting with Z (currently 3), got %r"%all_ids +- + Use the create_date column on res.country (which doesn't declare it in _columns). +- + !python {model: res.country }: | + ids = self.search(cr, uid, [('create_date', '<', '2001-01-01 12:00:00')]) +- diff --git a/openerp/osv/expression.py b/openerp/osv/expression.py index bbf4569cba8..272c1945d25 100644 --- a/openerp/osv/expression.py +++ b/openerp/osv/expression.py @@ -750,6 +750,10 @@ class expression(object): else: query = '(%s."%s" %s %s)' % (table._table, left, sql_operator, format) else: + # Ugly case to support columns present in database but not in + # _columns. This will probably be removed in the future, but + # we have to keep it for now. + _logger.warning("The domain term '%s' specify a column not declared in _columns." % ((left, operator, right),)) if self.has_unaccent and sql_operator in ('ilike', 'not ilike'): query = "(unaccent(%s.\"%s\") %s unaccent('%s'))" % (table._table, left, sql_operator, right) else: @@ -767,6 +771,10 @@ class expression(object): add_null = not str_utf8 elif left in table._columns: params = table._columns[left]._symbol_set[1](right) + else: + # Matching else clause for the above else clause, where the + # params are actually already in the query. + params = [] if add_null: query = '(%s OR %s."%s" IS NULL)' % (query, table._table, left)