[FIX] core/expression: fix 'not in' for translated fields
Domain terms of the form `('field', 'not in', [...])` generate incorrect
queries for translated fields, example (model `res.country`, field `name`):
```
psycopg2.errors.SyntaxError: syntax error at or near "ARRAY"
LINE 1: ...M "res_country" WHERE "res_country"."name" not in ARRAY['No ...
```
The root cause is that the right part of the term is not converted to
tuple.
Observed during the upgrade request 16639
opw-2525553
closes odoo/odoo#73030
X-original-commit: 7c4db97e21f74a429e56f6cae4d4786ee74f7e22
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
This commit is contained in:
committed by
Raphael Collet
parent
47ebaa384b
commit
003eb3b89d
@@ -704,6 +704,10 @@ class TestExpression(SavepointCaseWithUserDemo):
|
||||
countries = self._search(Country, domain)
|
||||
self.assertEqual(countries, belgium)
|
||||
|
||||
countries = self._search(Country, [('name', 'not in', ['No country'])])
|
||||
all_countries = self._search(Country, [])
|
||||
self.assertEqual(countries, all_countries)
|
||||
|
||||
@mute_logger('odoo.sql_db')
|
||||
def test_invalid(self):
|
||||
""" verify that invalid expressions are refused, even for magic fields """
|
||||
|
||||
@@ -909,7 +909,7 @@ class expression(object):
|
||||
sql_operator = {'=like': 'like', '=ilike': 'ilike'}.get(operator, operator)
|
||||
if need_wildcard:
|
||||
right = '%%%s%%' % right
|
||||
if sql_operator == 'in':
|
||||
if sql_operator in ('in', 'not in'):
|
||||
right = tuple(right)
|
||||
|
||||
unaccent = self._unaccent if sql_operator.endswith('like') else lambda x: x
|
||||
|
||||
Reference in New Issue
Block a user