From 079e90afbbe657d8c6c746a5911e27446302facd Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 10 Jul 2012 14:37:18 +0200 Subject: [PATCH] [ADD] successor method to list collections, to safely get the "next" record in a nested (groupby) context bzr revid: xmo@openerp.com-20120710123718-kiot6zzji07a4iao --- addons/web/static/src/js/view_list.js | 31 +++++++++-- .../web/static/src/js/view_list_editable.js | 8 +-- addons/web/static/test/list-utils.js | 51 ++++++++++++++++--- 3 files changed, 71 insertions(+), 19 deletions(-) diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 7c82d2b173f..2d1a06173cd 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -1849,7 +1849,7 @@ var Collection = instance.web.Class.extend(/** @lends Collection# */{ * @returns this */ remove: function (record) { - var index = _(this.records).indexOf(record); + var index = this.indexOf(record); if (index === -1) { _(this._proxies).each(function (proxy) { proxy.remove(record); @@ -1885,12 +1885,14 @@ var Collection = instance.web.Class.extend(/** @lends Collection# */{ // underscore-type methods find: function (callback) { - var record = null; + var record; for(var section in this._proxies) { - if (this._proxies.hasOwnProperty(section)) { - record = this._proxies[section].find(callback); + if (!this._proxies.hasOwnProperty(section)) { + continue + } + if ((record = this._proxies[section].find(callback))) { + return record; } - if (record) { return record; } } for(var i=0; i