diff --git a/CHANGELOG b/CHANGELOG index d5355f9317..d764e0be74 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/tryton/gui/window/view_form/widget_search/char.py b/tryton/gui/window/view_form/widget_search/char.py index 5ca974d86a..ffc5ef2f1a 100644 --- a/tryton/gui/window/view_form/widget_search/char.py +++ b/tryton/gui/window/view_form/widget_search/char.py @@ -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 [] diff --git a/tryton/gui/window/view_form/widget_search/reference.py b/tryton/gui/window/view_form/widget_search/reference.py index 75e052e683..228278348e 100644 --- a/tryton/gui/window/view_form/widget_search/reference.py +++ b/tryton/gui/window/view_form/widget_search/reference.py @@ -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 []