summaryrefslogtreecommitdiff
path: root/addons/base/controllers
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2011-03-23 13:08:06 +0100
committerXavier Morel <xmo@openerp.com>2011-03-23 13:08:06 +0100
commit801fae18ca92eecd9f6febcc15ec4f3ee0887cc4 (patch)
tree0cd3c7c0277164b8dfeee23f0839078b075f13b0 /addons/base/controllers
parent65c8aaf78b7e4cabbd3c2888c9e09e30297c748d (diff)
[ADD] implement forgotten DataSet.get RPC method, test it a bit
bzr revid: xmo@openerp.com-20110323120806-uhas8xvxnpsa1dm2
Diffstat (limited to 'addons/base/controllers')
-rw-r--r--addons/base/controllers/main.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/addons/base/controllers/main.py b/addons/base/controllers/main.py
index f5eda8020c5..723b0ae39dc 100644
--- a/addons/base/controllers/main.py
+++ b/addons/base/controllers/main.py
@@ -176,6 +176,9 @@ class DataSet(openerpweb.Controller):
domain, context, sort)
def do_find(self, request, model, fields=False, offset=0, limit=False,
domain=None, context=None, sort=None):
+ """ Performs a search() followed by a read() (if needed) using the
+ provided search criteria, only
+ """
Model = request.session.model(model)
ids = Model.search(domain or [], offset or 0, limit or False,
sort or False, context or False)
@@ -184,6 +187,30 @@ class DataSet(openerpweb.Controller):
return map(lambda id: {'id': id}, ids)
return Model.read(ids, fields or False)
+ @openerpweb.jsonrequest
+ def get(self, request, model, ids):
+ self.do_get(request, model, ids)
+
+ def do_get(self, request, model, ids):
+ """ Fetches and returns the records of the model ``model`` whose ids
+ are in ``ids``.
+
+ The results are in the same order as the inputs, but elements may be
+ missing (if there is no record left for the id)
+
+ :param request: the JSON-RPC2 request object
+ :type request: openerpweb.JsonRequest
+ :param model: the model to read from
+ :type model: str
+ :param ids: a list of identifiers
+ :type ids: list
+ """
+ Model = request.session.model(model)
+ records = Model.read(ids)
+
+ record_map = dict((record['id'], record) for record in records)
+
+ return [record_map[id] for id in ids if record_map.get(id)]
class DataRecord(openerpweb.Controller):
_cp_path = "/base/datarecord"