diff --git a/addons/base/static/src/js/data.js b/addons/base/static/src/js/data.js index e8886009dd9..9bd59cc0943 100644 --- a/addons/base/static/src/js/data.js +++ b/addons/base/static/src/js/data.js @@ -234,20 +234,19 @@ openerp.base.DataSet = openerp.base.Controller.extend( /** @lends openerp.base. this.model = model; this.context = context || {}; this.index = null; - this.count = 0; }, start: function() { }, previous: function () { this.index -= 1; if (this.index < 0) { - this.index = this.count - 1; + this.index = this.ids.length - 1; } return this; }, next: function () { this.index += 1; - if (this.index >= this.count) { + if (this.index >= this.ids.length) { this.index = 0; } return this; @@ -365,7 +364,6 @@ openerp.base.DataSetStatic = openerp.base.DataSet.extend({ this._super(session, model, context); // all local records this.ids = ids || []; - this.count = this.ids.length; if (this.ids.length) { this.index = 0; } @@ -378,9 +376,8 @@ openerp.base.DataSetStatic = openerp.base.DataSet.extend({ }, set_ids: function (ids) { this.ids = ids; - this.count = this.ids.length; - this.index = this.index <= this.count - 1 ? - this.index : (this.count > 0 ? this.count - 1 : 0); + this.index = this.index <= this.ids.length - 1 ? + this.index : (this.ids.length > 0 ? this.length - 1 : 0); }, unlink: function(ids) { this.on_unlink(ids); @@ -423,7 +420,6 @@ openerp.base.DataSetSearch = openerp.base.DataSet.extend({ }, function (records) { self.ids.splice(0, self.ids.length); self.offset = offset; - self.count = records.length; // TODO: get real count for (var i=0; i < records.length; i++ ) { self.ids.push(records[i].id); } @@ -463,9 +459,8 @@ openerp.base.DataSetSearch = openerp.base.DataSet.extend({ var self = this; return this._super(ids, function(result) { self.ids = _.without.apply(_, [self.ids].concat(ids)); - self.count = self.ids.length; - self.index = self.index <= self.count - 1 ? - self.index : (self.count > 0 ? self.count -1 : 0); + self.index = self.index <= self.ids.length - 1 ? + self.index : (self.ids.length > 0 ? self.ids.length -1 : 0); if (callback) callback(result); }, error_callback); diff --git a/addons/base/static/src/js/form.js b/addons/base/static/src/js/form.js index d279eb5d3aa..82f235f3893 100644 --- a/addons/base/static/src/js/form.js +++ b/addons/base/static/src/js/form.js @@ -157,7 +157,7 @@ openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormV var $pager = this.$element.find('#' + this.element_id + '_header div.oe_form_pager'); var index = hide_index ? '-' : this.dataset.index + 1; $pager.find('span.oe_pager_index').html(index); - $pager.find('span.oe_pager_count').html(this.dataset.count); + $pager.find('span.oe_pager_count').html(this.dataset.ids.length); }, do_onchange: function(widget, processed) { processed = processed || []; @@ -347,7 +347,6 @@ openerp.base.FormView = openerp.base.View.extend( /** @lends openerp.base.FormV this.dataset.ids.unshift(this.datarecord.id); this.dataset.index = 0; } - this.dataset.count++; this.do_update_pager(); this.do_update_sidebar(); this.notification.notify("Record created", "The record has been created with id #" + this.datarecord.id);