[FIX] dataset search, 'context' is popped from kwargs into the request object, and should be taken from there for RPC calls

bzr revid: xmo@openerp.com-20110411075846-9qxzabjav0y1l47n
This commit is contained in:
Xavier Morel
2011-04-11 09:58:46 +02:00
parent 669b109bde
commit f21bb336d3
2 changed files with 5 additions and 5 deletions
+2 -3
View File
@@ -334,18 +334,17 @@ class DataSet(openerpweb.Controller):
:param int offset: from which index should the results start being returned
:param int limit: the maximum number of records to return
:param list domain: the search domain for the query
:param dict context: the context in which the search should be executed
:param list sort: sorting directives
:returns: a list of result records
:rtype: list
"""
Model = request.session.model(model)
ids = Model.search(domain or [], offset or 0, limit or False,
sort or False, context or False)
sort or False, request.context)
if fields and fields == ['id']:
# shortcut read if we only want the ids
return map(lambda id: {'id': id}, ids)
return Model.read(ids, fields or False)
return Model.read(ids, fields or False, request.context)
@openerpweb.jsonrequest
def get(self, request, model, ids, fields=False):
+3 -2
View File
@@ -15,13 +15,14 @@ class TestDataSetController(unittest2.TestCase):
self.read.return_value = []
self.assertFalse(self.dataset.do_search_read(self.request, 'fake.model'))
self.read.assert_called_once_with([], False)
self.read.assert_called_once_with([], False, self.request.context)
def test_regular_find(self):
self.search.return_value = [1, 2, 3]
self.dataset.do_search_read(self.request, 'fake.model')
self.read.assert_called_once_with([1, 2, 3], False)
self.read.assert_called_once_with([1, 2, 3], False,
self.request.context)
def test_ids_shortcut(self):
self.search.return_value = [1, 2, 3]