[FIX] web: correctly export all records in list

Before this rev. a traceback occured when trying to export all records in a list
view.

An old reference to `searchView` was still present in the list controller, which
is not used anymore since the control panel refactoring (see odoo/odoo#29106).

Task 1917628

closes odoo/odoo#30073
This commit is contained in:
Martin Geubelle
2019-01-09 13:34:27 +00:00
parent c76066402c
commit d682137884
2 changed files with 5 additions and 33 deletions
@@ -71,15 +71,9 @@ var ListController = BasicController.extend({
// TODO: this method should be synchronous...
var self = this;
if (this.$('thead .o_list_record_selector input').prop('checked')) {
var searchData = this.searchView.build_search_data();
var userContext = this.getSession().user_context;
var results = pyUtils.eval_domains_and_contexts({
domains: searchData.domains,
contexts: [userContext].concat(searchData.contexts),
group_by_seq: searchData.groupbys || []
});
var searchQuery = this._controlPanel ? this._controlPanel.getSearchQuery() : {};
var record = self.model.get(self.handle, {raw: true});
return $.when(record.getDomain().concat(results.domain || []));
return $.when(record.getDomain().concat(searchQuery.domain || []));
} else {
return $.Deferred().resolve();
}
@@ -36,7 +36,7 @@ QUnit.module('widgets', {
QUnit.test('exporting all data in list view', function (assert) {
assert.expect(7);
assert.expect(6);
var blockUI = framework.blockUI;
var unblockUI = framework.unblockUI;
@@ -94,16 +94,6 @@ QUnit.module('widgets', {
},
});
list.searchView = {
build_search_data: function () {
assert.step('build_search_data');
return {
contexts: [],
domains: [],
groupbys: [],
};
},
};
testUtils.dom.click(list.$('thead th.o_list_record_selector input'));
testUtils.dom.click(list.sidebar.$('.o_dropdown_toggler_btn:contains(Action)'));
testUtils.dom.click(list.sidebar.$('a:contains(Export)'));
@@ -122,7 +112,6 @@ QUnit.module('widgets', {
framework.blockUI = blockUI;
framework.unblockUI = unblockUI;
assert.verifySteps([
'build_search_data',
'block UI',
'/web/export/csv',
'unblock UI',
@@ -130,7 +119,7 @@ QUnit.module('widgets', {
});
QUnit.test('saving fields list when exporting data', function (assert) {
assert.expect(6);
assert.expect(5);
var create = data.DataSet.prototype.create;
@@ -172,17 +161,6 @@ QUnit.module('widgets', {
},
});
list.searchView = {
build_search_data: function () {
assert.step('build_search_data');
return {
contexts: [],
domains: [],
groupbys: [],
};
},
};
// Open the export modal
testUtils.dom.click(list.$('thead th.o_list_record_selector input'));
testUtils.dom.click(list.sidebar.$('.o_dropdown_toggler_btn:contains(Action)'));
@@ -202,7 +180,7 @@ QUnit.module('widgets', {
testUtils.dom.click($('.modal a:contains(Save fields list)'));
testUtils.fields.editInput($('.modal .o_save_list > input'), 'fields list');
testUtils.dom.click($('.modal .o_save_list > button'));
assert.verifySteps(['build_search_data', 'create'],
assert.verifySteps(['create'],
"create should have been called");
// Close the modal and destroy list