[FIX] expression: allow exclusion of records with translated fields

lp bug: https://launchpad.net/bugs/1071710 fixed

bzr revid: chs@openerp.com-20140108152722-7f0dpsuv1skxbqub
This commit is contained in:
Christophe Simonis 2014-01-08 16:27:22 +01:00
parent 13063d5713
commit 7f8b6542f0
2 changed files with 21 additions and 4 deletions

View File

@ -535,12 +535,29 @@
-
!python {model: res.country}: |
# first install french language
BLI = self.pool.get('base.language.install')
BLI.lang_install(cr, uid, [BLI.create(cr, uid, {'lang': 'fr_FR'})])
Modules = self.pool.get('ir.module.module')
base = Modules.browse(cr, uid, Modules.search(cr, uid, [('name', '=', 'base')])[0])
# hack: mark module as installed to allow install of the translation
base_state = base.state
base.write({'state': 'installed'})
base.update_translations('fr_FR')
base.write({'state': base_state})
# tests
be_id = self.search(cr, uid, [('name', '=', 'Belgium')])[0]
ctx = {'lang': 'fr_FR'}
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)"

View File

@ -1026,9 +1026,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' \