summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/widgets/data_export_tests.js
diff options
context:
space:
mode:
authorOdoo's Mergebot <xmo+roboto@odoo.com>2019-09-20 17:13:47 +0200
committerGitHub <noreply@github.com>2019-09-20 17:13:47 +0200
commitf1aa96b0a8120e7adfb9ef217c70c2b3f4a991bc (patch)
treecf9562a69cb67c5c05a7077c7e31b758b7034521 /addons/web/static/tests/widgets/data_export_tests.js
parent3e21daaf457919087000e430e9ab1ba0ab93902b (diff)
parent5c4544fb2943e63fc1e0f5ae1e7e250a5a2b2cf1 (diff)
[MERGE] web: Re-implement the XLS grouped export
Purpose ======= The commit 2849b5c introduces a new export mechanism of grouped list views to xls files. The issue with this development is mainly that the displayed records are exported, instead of all the records that match the search parameters. To export all the records we cannot rely on the data from the web client. This implies to revert 2849b5c, and implement it in a better way. Functional Spec =============== Add the support of grouped exports. Allow the user to export all records in one click from the listview, without having to go through the export modal, taking into account the domain, groupbys, and visible fields. Technical Spec ============== When exporting (whether it is from the modal or from the shortcut), any groupby(s) set on the listview should be taken into account (all unfolded) - UNLESS the export is import-compatible - each subgroup header has an indentation compared to its parent - the 'group headers' in the exported file should contain the same info (label, field aggregates) as it has in the listview. New secondary button on the tree view with label 'EXPORT' (to be confirmed...) - the export shortcut disregard the selected records, it exports all records according to the domain. - the button is visible even if there is no selected records. - essentially the export shortcut does the same thing as the following: - select all records - hit 'action' then 'export' - hit 'export' Define a boolean attribute on <tree> to specify whether or not the export shortcut should be displayed Task 2072910 closes odoo/odoo#37087 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons/web/static/tests/widgets/data_export_tests.js')
-rw-r--r--addons/web/static/tests/widgets/data_export_tests.js116
1 files changed, 114 insertions, 2 deletions
diff --git a/addons/web/static/tests/widgets/data_export_tests.js b/addons/web/static/tests/widgets/data_export_tests.js
index 6d29e8e888d..c9c51219571 100644
--- a/addons/web/static/tests/widgets/data_export_tests.js
+++ b/addons/web/static/tests/widgets/data_export_tests.js
@@ -14,12 +14,22 @@ QUnit.module('widgets', {
partner: {
fields: {
foo: {string: "Foo", type: "char"},
+ bar: {string: "Bar", type: "char"},
},
records: [
{
id: 1,
foo: "yop",
- },
+ bar: "bar-blup",
+ }, {
+ id: 2,
+ foo: "yop",
+ bar: "bar-yop",
+ }, {
+ id: 3,
+ foo: "blup",
+ bar: "bar-blup",
+ }
]
},
'ir.exports': {
@@ -239,7 +249,7 @@ QUnit.module('widgets', {
},
});
// Open the export modal
- await testUtils.dom.click(list.$('.o_data_row .o_list_record_selector input'));
+ await testUtils.dom.click(list.$('thead .o_list_record_selector input'));
await testUtils.dom.click(list.sidebar.$('.o_dropdown_toggler_btn:contains(Action)'));
await testUtils.dom.click(list.sidebar.$('a:contains(Export)'));
@@ -257,6 +267,108 @@ QUnit.module('widgets', {
assert.strictEqual($('.modal .o_fields_list li').length, 1, "There should be only one field in list");
list.destroy();
});
+
+ QUnit.test('Direct export button invisible', async function (assert) {
+ assert.expect(1)
+
+ let list = await createView({
+ View: ListView,
+ model: 'partner',
+ data: this.data,
+ arch: `<tree export_xlsx="0"><field name="foo"/></tree>`,
+ });
+ assert.containsNone(list, '.o_list_export_xlsx')
+ list.destroy();
+ });
+
+ QUnit.test('Direct export list ', async function (assert) {
+ assert.expect(2)
+
+ let list = await createView({
+ View: ListView,
+ model: 'partner',
+ data: this.data,
+ arch: `
+ <tree export_xlsx="1">
+ <field name="foo"/>
+ <field name="bar"/>
+ </tree>`,
+ domain: [['bar', '!=', 'glou']],
+ session: {
+ get_file(args) {
+ let data = JSON.parse(args.data.data);
+ assert.strictEqual(args.url, '/web/export/xlsx', "should call get_file with the correct url");
+ assert.deepEqual(data, {
+ context: {},
+ model: 'partner',
+ domain: [['bar', '!=', 'glou']],
+ groupby: [],
+ ids: false,
+ import_compat: false,
+ fields: [{
+ name: 'foo',
+ label: 'Foo',
+ }, {
+ name: 'bar',
+ label: 'Bar',
+ }]
+ }, "should be called with correct params")
+ args.complete();
+ },
+ },
+ });
+
+ // select a record => should not be taken into account
+ await testUtils.dom.click(list.$('.o_data_row .o_list_record_selector input')[0]);
+ // Download
+ await testUtils.dom.click(list.$buttons.find('.o_list_export_xlsx'));
+
+ list.destroy();
+ });
+
+ QUnit.test('Direct export grouped list ', async function (assert) {
+ assert.expect(2)
+
+ let list = await createView({
+ View: ListView,
+ model: 'partner',
+ data: this.data,
+ debug: true,
+ arch: `
+ <tree>
+ <field name="foo"/>
+ <field name="bar"/>
+ </tree>`,
+ groupBy: ['foo', 'bar'],
+ domain: [['bar', '!=', 'glou']],
+ session: {
+ get_file(args) {
+ let data = JSON.parse(args.data.data);
+ assert.strictEqual(args.url, '/web/export/xlsx', "should call get_file with the correct url");
+ assert.deepEqual(data, {
+ context: {},
+ model: 'partner',
+ domain: [['bar', '!=', 'glou']],
+ groupby: ['foo', 'bar'],
+ ids: false,
+ import_compat: false,
+ fields: [{
+ name: 'foo',
+ label: 'Foo',
+ }, {
+ name: 'bar',
+ label: 'Bar',
+ }]
+ }, "should be called with correct params")
+ args.complete();
+ },
+ },
+ });
+
+ await testUtils.dom.click(list.$buttons.find('.o_list_export_xlsx'));
+
+ list.destroy();
+ });
});
});