[FIX] have page view force a return to the previous view if switched to with no record

lp bug: https://launchpad.net/bugs/900225 fixed

bzr revid: xmo@openerp.com-20111219125039-049o944efkkl2sk9
This commit is contained in:
Xavier Morel 2011-12-19 13:50:39 +01:00
parent eec5f1c6c4
commit d8df2d5e17
2 changed files with 13 additions and 2 deletions

View File

@ -252,14 +252,18 @@ openerp.web.DataSet = openerp.web.Widget.extend( /** @lends openerp.web.DataSet
},
previous: function () {
this.index -= 1;
if (this.index < 0) {
if (!this.ids.length) {
this.index = null;
} else if (this.index < 0) {
this.index = this.ids.length - 1;
}
return this;
},
next: function () {
this.index += 1;
if (this.index >= this.ids.length) {
if (!this.ids.length) {
this.index = null;
} else if (this.index >= this.ids.length) {
this.index = 0;
}
return this;

View File

@ -10,6 +10,13 @@ openerp.web.page = function (openerp) {
this._super.apply(this, arguments);
this.registry = openerp.web.page.readonly;
},
reload: function () {
if (this.dataset.index == null) {
this.do_prev_view();
return $.Deferred().reject().promise();
}
return this._super();
},
on_loaded: function(data) {
this._super(data);
this.$form_header.find('button.oe_form_button_edit').click(this.on_button_edit);