[FIX] web: reset offset in the search more view dialog
Start on the modal obtained by a "search more". The offset is never reset. So suppose you are on page 2, looking at record 81-160. Do a research that gives less than 80 records. The result of the search is nothing, since is has been done with a 80 offset. It should be reset to 0 when we do a new search. opw 1920826 closes odoo/odoo#30109
This commit is contained in:
@@ -264,7 +264,7 @@ var SelectCreateDialog = ViewDialog.extend({
|
||||
event.stopPropagation(); // prevent this event from bubbling up to the view manager
|
||||
var d = event.data;
|
||||
var searchData = this._process_search_data(d.domains, d.contexts, d.groupbys);
|
||||
this.list_controller.reload(searchData);
|
||||
this.list_controller.reload(_.extend({offset: 0}, searchData));
|
||||
},
|
||||
get_controller_context: '_onGetControllerContext',
|
||||
}),
|
||||
|
||||
@@ -525,6 +525,61 @@ QUnit.module('relational_fields', {
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('search more pager is reset when doing a new search', function (assert) {
|
||||
assert.expect(6);
|
||||
for(var i = 10; i < 180; i++) {
|
||||
this.data.partner.records.push({
|
||||
id: i,
|
||||
display_name: "Partner " + i,
|
||||
});
|
||||
}
|
||||
|
||||
function stringToEvent ($element, string) {
|
||||
for (var i = 0; i < string.length; i++) {
|
||||
var keyAscii = string.charCodeAt(i);
|
||||
$element.val($element.val()+string[i]);
|
||||
$element.trigger($.Event('keyup', {which: keyAscii, keyCode:keyAscii}));
|
||||
}
|
||||
$element.trigger($.Event('keyup', {which: $.ui.keyCode.ENTER, keyCode:$.ui.keyCode.ENTER}));
|
||||
}
|
||||
|
||||
this.data.partner.fields.datetime.searchable = true;
|
||||
var form = createView({
|
||||
View: FormView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch: '<form string="Partners">' +
|
||||
'<sheet>' +
|
||||
'<group>' +
|
||||
'<field name="trululu"/>' +
|
||||
'</group>' +
|
||||
'</sheet>' +
|
||||
'</form>',
|
||||
archs: {
|
||||
'partner,false,list': '<tree><field name="display_name"/></tree>',
|
||||
'partner,false,search': '<search><field name="datetime"/><field name="display_name"/></search>',
|
||||
},
|
||||
res_id: 1,
|
||||
});
|
||||
|
||||
form.$buttons.find('.o_form_button_edit').click();
|
||||
var $dropdown = form.$('.o_field_many2one input').autocomplete('widget');
|
||||
form.$('.o_field_many2one input').click();
|
||||
$dropdown.find('.o_m2o_dropdown_option:contains(Search)').mouseenter().click();
|
||||
$('.modal .o_pager_next').click();
|
||||
|
||||
assert.strictEqual($('.o_pager_limit').text(), "1173", "there should be 173 records");
|
||||
assert.strictEqual($('.o_pager_value').text(), "181-160", "should display the second page");
|
||||
assert.strictEqual($('tr.o_data_row').length, 80, "should display 80 record");
|
||||
|
||||
stringToEvent($('.modal .o_searchview_input'), 'first');
|
||||
|
||||
assert.strictEqual($('.o_pager_limit').text(), "11", "there should be 1 record");
|
||||
assert.strictEqual($('.o_pager_value').text(), "11-1", "should display the first page");
|
||||
assert.strictEqual($('tr.o_data_row').length, 1, "should display 1 record");
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('onchanges on many2ones trigger when editing record in form view', function (assert) {
|
||||
assert.expect(9);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user