[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
This commit is contained in:
Xavier Morel 2012-02-23 15:51:57 +01:00
parent 819334f0aa
commit a55e7148e3
1 changed files with 8 additions and 10 deletions

View File

@ -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};
}));