Chris Biersbach (OpenERP) has proposed merging lp:~openerp-dev/openobject-server/6.1-opw-581385-cbi into lp:openobject-server/6.1.
Requested reviews: OpenERP Core Team (openerp) For more details, see: https://code.launchpad.net/~openerp-dev/openobject-server/6.1-opw-581385-cbi/+merge/134259 The bug that was encountered: When using the negative operators in advanced filters, wrong results were shown when the language was not set to english The reason: If you search, for example, for countries that are not "Belgique", a union between the countries that do not have "Belgique" as original value and that do not have "Belgique" as french translation is made. This is incorrect, since it will return all the countries. This was done to allow the user to search using both the original value "Belgium" and the translated value "Belgique", and it works fine for the positive operators (in which case the union makes perfect sense), but not for the negative operators. The fix: When using negative operators, an intersection must be used instead of a union. -> Countries that are called "Belgique" OR whose translated value is "Belgique": Union -> Countries that are not called "Belgique" AND whose translation is not "Belgique": Intersection -> In logic: NOT(a OR b) == NOT a AND not b -- https://code.launchpad.net/~openerp-dev/openobject-server/6.1-opw-581385-cbi/+merge/134259 Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-server/6.1-opw-581385-cbi.
=== modified file 'openerp/osv/expression.py' --- openerp/osv/expression.py 2012-01-24 12:42:52 +0000 +++ openerp/osv/expression.py 2012-11-14 08:17:23 +0000 @@ -629,16 +629,20 @@ ' AND type = %s' instr = ' %s' #Covering in,not in operators with operands (%s,%s) ,etc. + if sql_operator in NEGATIVE_TERM_OPERATORS: + op = 'INTERSECT' + else: + op = 'UNION' if sql_operator in ['in','not in']: instr = ','.join(['%s'] * len(right)) subselect += ' AND value ' + sql_operator + ' ' +" (" + instr + ")" \ - ') UNION (' \ + ') ' + op + ' (' \ ' SELECT id' \ ' FROM "' + working_table._table + '"' \ ' WHERE "' + left + '" ' + sql_operator + ' ' +" (" + instr + "))" else: subselect += ' AND value ' + sql_operator + instr + \ - ') UNION (' \ + ') ' + op + ' (' \ ' SELECT id' \ ' FROM "' + working_table._table + '"' \ ' WHERE "' + left + '" ' + sql_operator + instr + ")"
_______________________________________________ Mailing list: https://launchpad.net/~openerp-dev-gtk Post to : openerp-dev-gtk@lists.launchpad.net Unsubscribe : https://launchpad.net/~openerp-dev-gtk More help : https://help.launchpad.net/ListHelp