Fix for new like and ilike behavior

Add 'starts with' and 'ends with' on char search
This commit is contained in:
Cédric Krier committed 2009-05-27 19:41:42 +02:00
1 parent 8f6e17e80d
commit 1f35557fc8
3 files changed
+13 -2

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Add 'starts with' and 'ends with' on char search
* Handle domain with '=' or '!=' as operator on selection
* Extend fields domain with local domains
* Improve float time widget to handle year, month, week and day
@@ -20,10 +20,13 @@ class Char(Interface):
cell = gtk.CellRendererText()
self.combo.pack_start(cell, True)
self.combo.add_attribute(cell, 'text', 1)
for oper in (['ilike', _('contains')],
for oper in (
['ilike', _('contains')],
['not ilike', _('does not contain')],
['=', _('equals')],
['!=', _('does not equal')],
['starts', _('starts with')],
['ends', _('ends with')],
):
self.liststore.append(oper)
self.combo.set_active(0)
@@ -42,6 +45,13 @@ class Char(Interface):
if value or oper != 'ilike':
if oper == '=' and not value:
value = False
if oper in ('ilike', 'not ilike') \
and '%' not in value:
return [(self.name, oper, '%' + value + '%')]
elif oper == 'starts':
return [(self.name, 'ilike', value + '%')]
elif oper == 'ends':
return [(self.name, 'ilike', '%' + value)]
return [(self.name, oper, value)]
else:
return []
@@ -93,7 +93,7 @@ class Reference(Interface):
value = self._selection.get(self.entry.child.get_text(), False)
oper = self.liststore.get_value(self.combo.get_active_iter(), 0)
if value or oper != 'like':
return [(self.name, oper, value + ',')]
return [(self.name, oper, value + ',%')]
else:
self.entry.child.set_text('')
return []