diff options
| author | niv-openerp <nicolas.vanhoren@openerp.com> | 2011-09-06 11:50:54 +0200 |
|---|---|---|
| committer | niv-openerp <nicolas.vanhoren@openerp.com> | 2011-09-06 11:50:54 +0200 |
| commit | f7544bb989ffc0b9bb3d19fc86b44a6a1086e0ee (patch) | |
| tree | ddad548306d76c0c7e654c8c4fca47eb7cea6374 /addons/web/static/src/js/data.js | |
| parent | baed408025a5c4dedf1eac52d2cf78063da78e71 (diff) | |
| parent | 71cb3b3bc38bcf4f69398138c8193f0fde5d213e (diff) | |
[imp] lot of improvements to header & about page
bzr revid: nicolas.vanhoren@openerp.com-20110906095054-qjlpmyd83spjm79b
Diffstat (limited to 'addons/web/static/src/js/data.js')
| -rw-r--r-- | addons/web/static/src/js/data.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index 3797121756f..4b4523a2723 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -737,6 +737,50 @@ openerp.web.ReadOnlyDataSetSearch = openerp.web.DataSetSearch.extend({ on_unlink: function(ids) {} }); +openerp.web.Model = openerp.web.SessionAware.extend({ + init: function(session, model_name) { + this._super(session); + this.model_name = model_name; + }, + get_func: function(method_name) { + var self = this; + return function() { + if (method_name == "search_read") + return self._search_read.apply(self, arguments); + return self._call(method_name, _.toArray(arguments)); + }; + }, + _call: function (method, args) { + return this.rpc('/web/dataset/call', { + model: this.model_name, + method: method, + args: args + }).pipe(function(result) { + if (method == "read" && result instanceof Array && result.length > 0 && result[0]["id"]) { + var index = {}; + _.each(_.range(result.length), function(i) { + index[result[i]["id"]] = result[i]; + }) + result = _.map(args[0], function(x) {return index[x];}); + } + return result; + }); + }, + _search_read: function(domain, fields, offset, limit, order, context) { + return this.rpc('/web/dataset/search_read', { + model: this.model_name, + fields: fields, + offset: offset, + limit: limit, + domain: domain, + sort: order, + context: context + }).pipe(function(result) { + return result.records; + });; + } +}); + openerp.web.CompoundContext = openerp.web.Class.extend({ init: function () { this.__ref = "compound_context"; |
