[FIX] have page view force a return to the previous view if switched to with no record
authorXavier Morel <xmo@openerp.com>
Mon, 19 Dec 2011 12:50:39 +0000 (13:50 +0100)
committerXavier Morel <xmo@openerp.com>
Mon, 19 Dec 2011 12:50:39 +0000 (13:50 +0100)
lp bug: https://launchpad.net/bugs/900225 fixed

bzr revid: xmo@openerp.com-20111219125039-049o944efkkl2sk9

addons/web/static/src/js/data.js
addons/web/static/src/js/view_page.js

index 46393aa..f3a364e 100644 (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;
index 5474bcd..428776e 100644 (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);