From a55e7148e344319c70fb7c9bc7fa41b0d94c06b4 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 23 Feb 2012 15:51:57 +0100 Subject: [PATCH] [FIX] correctly set dataset index when selecting a record in list view, so switching to page/form switches to the first selected record, not the first record of the page lp bug: https://launchpad.net/bugs/939314 fixed bzr revid: xmo@openerp.com-20120223145157-rkkwg6pwcr6hh7st --- addons/web/static/src/js/view_list.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index eb13bbd927b..ec8e6a17c87 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -540,19 +540,17 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView# * @param {Array} records selected record values */ do_select: function (ids, records) { - this.$element.find('.oe-list-delete') - .attr('disabled', !ids.length); - if (this.sidebar) { - if (ids.length) { - this.sidebar.do_unfold(); - } else { - this.sidebar.do_fold(); - } - } - if (!records.length) { + this.$element.find('.oe-list-delete').attr('disabled', !ids.length); + if (!ids.length) { + this.dataset.index = 0; + if (this.sidebar) { this.sidebar.do_fold(); } this.compute_aggregates(); return; } + + this.dataset.index = _(this.dataset.ids).indexOf(ids[0]); + if (this.sidebar) { this.sidebar.do_unfold(); } + this.compute_aggregates(_(records).map(function (record) { return {count: 1, values: record}; }));