[FIX] static datasets: don't set the index to 0 if there are no ids at all, the form...
authorXavier Morel <xmo@openerp.com>
Thu, 15 Dec 2011 15:41:00 +0000 (16:41 +0100)
committerXavier Morel <xmo@openerp.com>
Thu, 15 Dec 2011 15:41:00 +0000 (16:41 +0100)
lp bug: https://launchpad.net/bugs/899043 fixed

bzr revid: xmo@openerp.com-20111215154100-aspzga71cng767u8

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

index aec701e..46393aa 100644 (file)
@@ -510,9 +510,10 @@ openerp.web.DataSetStatic =  openerp.web.DataSet.extend({
     },
     set_ids: function (ids) {
         this.ids = ids;
-        if (this.index !== null) {
-            this.index = this.index <= this.ids.length - 1 ?
-                this.index : (this.ids.length > 0 ? this.length - 1 : 0);
+        if (ids.length === 0) {
+            this.index = null;
+        } else if (this.index >= ids.length - 1) {
+            this.index = ids.length - 1;
         }
     },
     unlink: function(ids) {