Reduce offset when no search result

issue7966
review60461002
This commit is contained in:
Cédric Krier
2019-01-18 11:17:07 +01:00
parent 9b07e6a7bc
commit 0b08bf2eed
2 changed files with 16 additions and 4 deletions
+1
View File
@@ -1,3 +1,4 @@
* Reduce offset when no search result
* Add support for plugins
* Add support for expand, height and width attributes
* Add drag & drop support on attachment button
+15 -4
View File
@@ -907,9 +907,20 @@
if (this.screen_container.but_active.hasClass('active')) {
context.active_test = false;
}
return this.model.execute(
'search', [domain, this.offset, this.limit, this.order],
context).then(function(ids) {
var search = function() {
return this.model.execute(
'search', [domain, this.offset, this.limit, this.order],
context)
.then(function(ids) {
if (ids.length || this.offset <= 0) {
return ids;
} else {
this.offset = Math.max(this.offset - this.limit, 0);
return search();
}
}.bind(this));
}.bind(this);
return search().then(function(ids) {
this.search_count = ids.length;
var count_prm = jQuery.when(this.search_count);
if ((!only_ids) &&
@@ -1579,7 +1590,7 @@
},
search_prev: function(search_string) {
if (this.limit) {
this.offset -= this.limit;
this.offset = Math.max(this.offset - this.limit, 0);
}
this.search_filter(search_string);
},