Fix ilike search when there is no value
This commit is contained in:
1 parent
dc4471f655
commit
bc247e2e64
5 files changed
+55
-29
No files matched your search
@@ -79,9 +79,12 @@ class Many2Many(WidgetInterface):
|
||||
value = self.wid_text.get_text()
|
||||
|
||||
try:
|
||||
if value:
|
||||
dom = [('rec_name', 'ilike', '%' + value + '%'), domain]
|
||||
else:
|
||||
dom = domain
|
||||
ids = rpc.execute('model', self.attrs['relation'], 'search',
|
||||
[('rec_name', 'ilike', '%' + value + '%'), domain], 0,
|
||||
_LIMIT, None, context)
|
||||
dom , 0, _LIMIT, None, context)
|
||||
except Exception, exception:
|
||||
common.process_exception(exception, self._window)
|
||||
return False
|
||||
|
||||
@@ -281,11 +281,14 @@ class Many2One(WidgetInterface):
|
||||
self.wid_text.grab_focus()
|
||||
|
||||
try:
|
||||
if self.wid_text.get_text():
|
||||
dom = [('rec_name', 'ilike',
|
||||
'%' + self.wid_text.get_text() + '%'),
|
||||
domain]
|
||||
else:
|
||||
dom = domain
|
||||
ids = rpc.execute('model', self.attrs['relation'],
|
||||
'search',
|
||||
[('rec_name', 'ilike',
|
||||
'%' + self.wid_text.get_text() + '%'),
|
||||
domain], 0, _LIMIT, None, context)
|
||||
'search', dom, 0, _LIMIT, None, context)
|
||||
except Exception, exception:
|
||||
self.focus_out = True
|
||||
common.process_exception(exception, self._window)
|
||||
@@ -355,11 +358,14 @@ class Many2One(WidgetInterface):
|
||||
self.wid_text.grab_focus()
|
||||
|
||||
try:
|
||||
if self.wid_text.get_text():
|
||||
dom = [('rec_name', 'ilike',
|
||||
'%' + self.wid_text.get_text() + '%'),
|
||||
domain]
|
||||
else:
|
||||
dom = domain
|
||||
ids = rpc.execute('model', self.attrs['relation'],
|
||||
'search',
|
||||
[('rec_name', 'ilike',
|
||||
'%' + self.wid_text.get_text() +'%'),
|
||||
domain], 0, _LIMIT, None, context)
|
||||
'search', dom, 0, _LIMIT, None, context)
|
||||
except Exception, exception:
|
||||
self.focus_out = True
|
||||
common.process_exception(exception, self._window)
|
||||
|
||||
@@ -378,11 +378,13 @@ class Dialog(object):
|
||||
context = rpc.CONTEXT.copy()
|
||||
|
||||
try:
|
||||
if self.wid_text.get_text():
|
||||
dom = [('rec_name', 'ilike',
|
||||
'%' + self.wid_text.get_text() + '%'), domain]
|
||||
else:
|
||||
dom = domain
|
||||
ids = rpc.execute('model', self.attrs['relation'],
|
||||
'search',
|
||||
[('rec_name', 'ilike',
|
||||
'%' + self.wid_text.get_text() + '%'), domain],
|
||||
0, _LIMIT, None, context)
|
||||
'search', dom, 0, _LIMIT, None, context)
|
||||
except Exception, exception:
|
||||
common.process_exception(exception, self._window)
|
||||
return False
|
||||
@@ -605,11 +607,13 @@ class One2Many(WidgetInterface):
|
||||
removed_ids = self._view.modelfield.get_removed_ids(self._view.model)
|
||||
|
||||
try:
|
||||
if self.wid_text.get_text():
|
||||
dom = [('rec_name', 'ilike', '%' + self.wid_text.get_text() + '%'),
|
||||
['OR', domain, ('id', 'in', removed_ids)]]
|
||||
else:
|
||||
dom = ['OR', domain, ('id', 'in', removed_ids)]
|
||||
ids = rpc.execute('model', self.attrs['relation'],
|
||||
'search',
|
||||
[('rec_name', 'ilike', '%' + self.wid_text.get_text() + '%'),
|
||||
['OR', domain, ('id', 'in', removed_ids)]],
|
||||
0, _LIMIT, None, context)
|
||||
'search', dom, 0, _LIMIT, None, context)
|
||||
except Exception, exception:
|
||||
common.process_exception(exception, self._window)
|
||||
return False
|
||||
|
||||
@@ -167,11 +167,14 @@ class Reference(WidgetInterface):
|
||||
context = self._view.modelfield.context_get(self._view.model)
|
||||
|
||||
try:
|
||||
ids = rpc.execute('model', model,
|
||||
'search',
|
||||
[('rec_name', 'ilike',
|
||||
if self.wid_text.get_text():
|
||||
dom = [('rec_name', 'ilike',
|
||||
'%' + self.wid_text.get_text() + '%'),
|
||||
domain], 0, _LIMIT, None, context)
|
||||
domain]
|
||||
else:
|
||||
dom = domain
|
||||
ids = rpc.execute('model', model,
|
||||
'search', dom, 0, _LIMIT, None, context)
|
||||
except Exception, exception:
|
||||
self.focus_out = True
|
||||
self.changed = True
|
||||
|
||||
@@ -508,8 +508,12 @@ class M2O(Char):
|
||||
context = model[self.field_name].context_get(model)
|
||||
|
||||
try:
|
||||
ids = rpc_relation.search([('rec_name', 'ilike', '%' + text + '%'),
|
||||
domain], 0, None, None, context)
|
||||
if text:
|
||||
dom = [('rec_name', 'ilike', '%' + text + '%'),
|
||||
domain]
|
||||
else:
|
||||
dom = domain
|
||||
ids = rpc_relation.search(dom, 0, None, None, context)
|
||||
except Exception, exception:
|
||||
common.process_exception(exception, self.window)
|
||||
return '???'
|
||||
@@ -532,9 +536,11 @@ class M2O(Char):
|
||||
rpc_relation = RPCProxy(relation)
|
||||
|
||||
try:
|
||||
ids = rpc_relation.search([
|
||||
('rec_name', 'ilike', '%' + text + '%'), domain],
|
||||
0, None, None, context)
|
||||
if text:
|
||||
dom = [('rec_name', 'ilike', '%' + text + '%'), domain]
|
||||
else:
|
||||
dom = domain
|
||||
ids = rpc_relation.search(dom, 0, None, None, context)
|
||||
except Exception, exception:
|
||||
common.process_exception(exception, self.window)
|
||||
return False, False
|
||||
@@ -627,8 +633,12 @@ class M2M(Char):
|
||||
domain = model[self.field_name].domain_get(model)
|
||||
context = model[self.field_name].context_get(model)
|
||||
try:
|
||||
ids = rpc_relation.search([('rec_name', 'ilike', '%' + text + '%'),
|
||||
domain], 0, _LIMIT, None, context)
|
||||
if text:
|
||||
dom = [('rec_name', 'ilike', '%' + text + '%'),
|
||||
domain]
|
||||
else:
|
||||
dom = domain
|
||||
ids = rpc_relation.search(dom, 0, _LIMIT, None, context)
|
||||
except Exception, exception:
|
||||
common.process_exception(exception, self.window)
|
||||
return []
|
||||
|
||||
Reference in new issue
Block a user