[FIX] expression: allow exclusion of records with translated fields
authorChristophe Simonis <chs@openerp.com>
Wed, 8 Jan 2014 14:13:18 +0000 (15:13 +0100)
committerChristophe Simonis <chs@openerp.com>
Wed, 8 Jan 2014 14:13:18 +0000 (15:13 +0100)
lp bug: https://launchpad.net/bugs/1071710 fixed

bzr revid: chs@openerp.com-20140108141318-erw2gdv982903buz

openerp/addons/base/test/test_osv_expression.yml
openerp/osv/expression.py

index 3de0c92..7a8254c 100644 (file)
         not_be = self.search(cr, uid, [('name', '!=', 'Belgique')], context=ctx)
 
         assert be_id not in not_be, "Search match failed"
+
+        # indirect search via m2o
+        Partners = self.pool.get('res.partner')
+        agrolait = Partners.search(cr, uid, [('name', '=', 'Agrolait')])[0]
+
+        not_be = Partners.search(cr, uid, [('country_id', '!=', 'Belgium')])
+        assert agrolait not in not_be, "Search match failed (m2o)"
+
+        not_be = Partners.search(cr, uid, [('country_id', '!=', 'Belgique')], context=ctx)
+        assert agrolait not in not_be, "Search match failed (m2o)"
index 5d92695..27efdaa 100644 (file)
@@ -624,9 +624,9 @@ class expression(object):
                         right = '%%%s%%' % right
 
                     inselect_operator = 'inselect'
-                    if operator in NEGATIVE_TERM_OPERATORS:
+                    if sql_operator in NEGATIVE_TERM_OPERATORS:
                         # negate operator (fix lp:1071710)
-                        operator = operator[4:] if operator[:3] == 'not' else '='
+                        sql_operator = sql_operator[4:] if sql_operator[:3] == 'not' else '='
                         inselect_operator = 'not inselect'
 
                     subselect = '( SELECT res_id'          \