Nimesh Contractor(Open ERP) has proposed merging
lp:~openerp-dev/openobject-server/trunk-bug-788106-nco into
lp:openobject-server.
Requested reviews:
Naresh(OpenERP) (nch-openerp)
Related bugs:
Bug #788106 in OpenERP Server: "[6.0 - trunk] cannot search translatable
field with =ilike operator"
https://bugs.launchpad.net/openobject-server/+bug/788106
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-bug-788106-nco/+merge/64277
Hello,
Add yml test-case for =like and =ilike operator for translatable filed and non
translatable filed
Thank you.
--
https://code.launchpad.net/~openerp-dev/openobject-server/trunk-bug-788106-nco/+merge/64277
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-server/trunk-bug-788106-nco.
=== modified file 'openerp/addons/base/test/test_osv_expression.yml'
--- openerp/addons/base/test/test_osv_expression.yml 2010-12-29 17:42:23 +0000
+++ openerp/addons/base/test/test_osv_expression.yml 2011-06-11 06:03:30 +0000
@@ -111,3 +111,29 @@
res_ids.sort()
assert res_ids == all_ids, "Searching against empty set failed, returns %r" % res_ids
+-
+ Check that =like expressions is working without translation field
+-
+ !python {model: res.partner }: |
+ all_ids = self.search(cr, uid, [('name', '=like', 'Ax')])
+ assert len(all_ids) <= 1,"with =like operator without translation field, returns"
+
+-
+ Check that =ilike expression is working without translation field
+-
+ !python {model: res.partner }: |
+ all_ids = self.search(cr, uid, [('name', '=ilike', 'Ax')])
+ assert len(all_ids) <= 2,"with =ilike operator without translation field, returns"
+-
+ Check that =like expression is working with translation field
+-
+ !python {model: res.country }: |
+ all_ids = self.search(cr, uid, [('name', '=like', 'Ind')])
+ assert len(all_ids) <= 3,"with =like operator with translation field, returns"
+
+-
+ Check that =ilike expression is working with translation field
+-
+ !python {model: res.country }: |
+ all_ids = self.search(cr, uid, [('name', '=ilike', 'Ind')])
+ assert len(all_ids) <= 3,"with =ilike operator with translation field, returns"
\ No newline at end of file
=== modified file 'openerp/osv/expression.py'
--- openerp/osv/expression.py 2011-02-07 12:57:23 +0000
+++ openerp/osv/expression.py 2011-06-11 06:03:30 +0000
@@ -353,11 +353,10 @@
self.__exp[i] = tuple(self.__exp[i])
if field.translate:
+ operator = {'=like':'like','=ilike':'ilike'}.get(operator,operator)
if operator in ('like', 'ilike', 'not like', 'not ilike'):
right = '%%%s%%' % right
-
- operator = operator == '=like' and 'like' or operator
-
+
query1 = '( SELECT res_id' \
' FROM ir_translation' \
' WHERE name = %s' \
@@ -451,8 +450,9 @@
query = '%s.id %s %%s' % (table._table, operator)
params = right
else:
+ operator = {'=like':'like','=ilike':'ilike'}.get(operator,operator)
like = operator in ('like', 'ilike', 'not like', 'not ilike')
-
+
op = {'=like':'like','=ilike':'ilike'}.get(operator,operator)
if left in table._columns:
format = like and '%s' or table._columns[left]._symbol_set[0]
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp