diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index 36c8eda9028..2b82e618203 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -349,85 +349,6 @@ instance.web.Model = instance.web.Class.extend({ }, }); -instance.web.Traverser = instance.web.Class.extend({ - /** - * @constructs instance.web.Traverser - * @extends instance.web.Class - * - * @param {instance.web.Model} model instance this traverser is bound to - */ - init: function (model) { - this._model = model; - this._index = 0; - }, - - /** - * Gets and sets the current index - * - * @param {Number} [idx] - * @returns {Number} current index - */ - index: function (idx) { - if (idx) { this._index = idx; } - return this._index; - }, - /** - * Returns the model this traverser is currently bound to - * - * @returns {openerp.web.Model} - */ - model: function () { - return this._model; - }, - /** - * Fetches the size of the backing model's match - * - * @returns {Deferred} deferred count - */ - size: function () { - return this._model.query().count(); - }, - - /** - * Record at the current index for the collection, fails if there is no - * record at the current index. - * - * @returns {Deferred<>} - */ - current: function (fields) { - return this._model.query(fields).first().pipe(function (record) { - if (record == null) { - return $.Deferred() - .reject('No record at index' + this._index) - .promise(); - } - return record; - }); - }, - next: function (fields) { - var self = this; - this._index++; - return this.size().pipe(function (s) { - if (self._index >= s) { - self._index = 0; - } - return self.current(fields); - }); - }, - previous: function (fields) { - var self = this; - this._index--; - if (this._index < 0) { - return this.size().pipe(function (s) { - self._index = s-1; - return self.current(fields); - }); - } - return this.current(fields); - } - -}); - instance.web.DataGroup = instance.web.CallbackEnabled.extend({ /** * Management interface between views and grouped collections of OpenERP @@ -513,8 +434,7 @@ instance.web.StaticDataGroup = instance.web.DataGroup.extend({ instance.web.DataSet = instance.web.CallbackEnabled.extend({ /** - * DateaManagement interface between views and the collection of selected - * OpenERP records (represents the view's state?) + * Collection of OpenERP records, used to share records and the current selection between views. * * @constructs instance.web.DataSet * @extends instance.web.CallbackEnabled @@ -631,8 +551,6 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({ * Creates a new record in db * * @param {Object} data field values to set on the new record - * @param {Function} callback function called with operation result - * @param {Function} error_callback function called in case of creation error * @returns {$.Deferred} */ create: function(data) { @@ -655,8 +573,6 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({ * Deletes an existing record from the database * * @param {Number|String} ids identifier of the record to delete - * @param {Function} callback function called with operation result - * @param {Function} error_callback function called in case of deletion error */ unlink: function(ids) { return this._model.call('unlink', [ids], {context: this._model.context()}); @@ -680,8 +596,6 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({ * @param {Array} [args] * @param {Number} [domain_index] index of a domain to evaluate in the args array * @param {Number} [context_index] index of a context to evaluate in the args array - * @param {Function} callback - * @param {Function} error_callback * @returns {$.Deferred} */ call_and_eval: function (method, args, domain_index, context_index) { @@ -698,8 +612,6 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({ * * @param {String} method * @param {Array} [args] - * @param {Function} callback - * @param {Function} error_callback * @returns {$.Deferred} */ call_button: function (method, args) { @@ -709,7 +621,6 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({ * Fetches the "readable name" for records, based on intrinsic rules * * @param {Array} ids - * @param {Function} callback * @returns {$.Deferred} */ name_get: function(ids) { @@ -735,7 +646,6 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({ }, /** * @param name - * @param callback */ name_create: function(name) { return this._model.call('name_create', [name], {context: this._model.context()}); @@ -795,6 +705,7 @@ instance.web.DataSet = instance.web.CallbackEnabled.extend({ }); }, }); + instance.web.DataSetStatic = instance.web.DataSet.extend({ init: function(parent, model, context, ids) { this._super(parent, model, context); @@ -825,6 +736,7 @@ instance.web.DataSetStatic = instance.web.DataSet.extend({ this.set_ids(_.without.apply(null, [this.ids].concat(ids))); } }); + instance.web.DataSetSearch = instance.web.DataSet.extend({ /** * @constructs instance.web.DataSetSearch @@ -893,6 +805,7 @@ instance.web.DataSetSearch = instance.web.DataSet.extend({ return this._super(); } }); + instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({ virtual_id_prefix: "one2many_v_id_", debug_mode: true, @@ -964,7 +877,8 @@ instance.web.BufferedDataSet = instance.web.DataSetStatic.extend({ this.cache = []; this.delete_all = false; }, - on_change: function() {}, + on_change: function() { + }, read_ids: function (ids, fields, options) { var self = this; var to_get = []; diff --git a/doc/rpc.rst b/doc/rpc.rst index 5c5ca11b07d..d083f87d251 100644 --- a/doc/rpc.rst +++ b/doc/rpc.rst @@ -240,75 +240,6 @@ regular query for records): The result of a (successful) :js:func:`~openerp.web.Query.group_by` is an array of :js:class:`~openerp.web.data.Group`. -Synchronizing views (provisional) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. note:: this API may not be final, and may not even remain - -While the high-level RPC API is mostly stateless, some objects in -OpenERP Web need to share state information. One of those is OpenERP -views, especially between "collection-based" views (lists, graphs) and -"record-based" views (forms, diagrams), which gets its very own API -for traversing collections of records, the aptly-named -:js:class:`~openerp.web.Traverser`. - -A :js:class:`~openerp.web.Traverser` is linked to a -:js:class:`~openerp.web.Model` and is used to iterate over it -asynchronously (and using indexes). - -.. js:class:: openerp.web.Traverser(model) - - .. js:function:: openerp.web.Traverser.model() - - :returns: the :js:class:`~openerp.web.Model` this traverser - instance is bound to - - .. js:function:: openerp.web.Traverser.index([idx]) - - If provided with an index parameter, sets that as the new - index for the traverser. - - :param Number idx: the new index for the traverser - :returns: the current index for the traverser - - .. js:function:: openerp.web.Traverser.current([fields]) - - Fetches the traverser's "current" record (that is, the record - at the current index of the traverser) - - :param Array fields: fields to return in the record - :rtype: Deferred<> - - .. js:function:: openerp.web.Traverser.next([fields]) - - Increases the traverser's internal index by one, the fetches - the corresponding record. Roughly equivalent to: - - .. code-block:: javascript - - var idx = traverser.index(); - traverser.index(idx+1); - traverser.current(); - - :param Array fields: fields to return in the record - :rtype: Deferred<> - - .. js:function:: openerp.web.Traverser.previous([fields]) - - Similar to :js:func:`~openerp.web.Traverser.next` but iterates - the traverser backwards rather than forward. - - :param Array fields: fields to return in the record - :rtype: Deferred<> - - .. js:function:: openerp.web.Traverser.size() - - Shortcut to checking the size of the backing model, calling - ``traverser.size()`` is equivalent to calling - ``traverser.model().query([]).count()`` - - :rtype: Deferred - Low-level API: RPC calls to Python side ---------------------------------------