[FIX] web: filter out non-exportable fields
Go to User list With studio add column User type export Traceback will occur because the special field sel_groups_* should not be exported opw-2565911 closes odoo/odoo#72861 X-original-commit: 196fe4c0be19310964b41da3b8a113f6d81aed6e Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
This commit is contained in:
@@ -398,7 +398,7 @@ var ListController = BasicController.extend({
|
||||
*/
|
||||
_getExportDialogWidget() {
|
||||
let state = this.model.get(this.handle);
|
||||
let defaultExportFields = this.renderer.columns.filter(field => field.tag === 'field').map(field => field.attrs.name);
|
||||
let defaultExportFields = this.renderer.columns.filter(field => field.tag === 'field' && state.fields[field.attrs.name].exportable !== false).map(field => field.attrs.name);
|
||||
let groupedBy = this.renderer.state.groupedBy;
|
||||
const domain = this.isDomainSelected && state.getDomain();
|
||||
return new DataExport(this, state, defaultExportFields, groupedBy,
|
||||
|
||||
@@ -16,6 +16,7 @@ QUnit.module('widgets', {
|
||||
fields: {
|
||||
foo: {string: "Foo", type: "char"},
|
||||
bar: {string: "Bar", type: "char"},
|
||||
unexportable: {string: "Unexportable", type: "boolean", exportable: false},
|
||||
},
|
||||
records: [
|
||||
{
|
||||
@@ -193,6 +194,35 @@ QUnit.module('widgets', {
|
||||
list.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('exporting view with non-exportable field', async function (assert) {
|
||||
assert.expect(0);
|
||||
|
||||
var list = await createView({
|
||||
View: ListView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch: '<tree><field name="unexportable"/></tree>',
|
||||
viewOptions: {
|
||||
hasActionMenus: true,
|
||||
},
|
||||
mockRPC: this.mockDataExportRPCs,
|
||||
session: {
|
||||
...this.mockSession,
|
||||
get_file: function (params) {
|
||||
assert.step(params.url);
|
||||
params.complete();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await testUtils.dom.click(list.$('thead th.o_list_record_selector input'));
|
||||
|
||||
await cpHelpers.toggleActionMenu(list);
|
||||
await cpHelpers.toggleMenuItem(list, 'Export');
|
||||
|
||||
list.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('saving fields list when exporting data', async function (assert) {
|
||||
assert.expect(4);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user