summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/views/graph_tests.js
diff options
context:
space:
mode:
authorOdoo's Mergebot <robodoo@odoo.com>2020-08-18 12:44:27 +0200
committerGitHub <noreply@github.com>2020-08-18 12:44:27 +0200
commiteee563ae1a0c17dbecefbbaa64bd4765c8a80350 (patch)
treecacc70a41777ba213bd54a4d02b8f69cb8a3ba30 /addons/web/static/tests/views/graph_tests.js
parent29b44207c9d59473c9532713aed20b01f6a36d0e (diff)
parentd8635586630ff8c47fff26ca9c6a20a6bb459489 (diff)
[MERGE] crm_*: hide irrelevant measures from graph/pivot views
PURPOSE Support invisible attributes to remove irrelevant fields in standard views. SPECIFICATIONS Add the possibility to not display some fields in the measures dropdown for the graph and pivot views. When a field is not displayed in the measures of a pivot views we remove them also from the list of groupable fields. Update CRM addons to hide irrelevant measures. LINKS Task ID-2288381 Community PR #54774 Enterprise PR odoo/enterprise#11970 Upgrade PR odoo/upgrade#1519 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Diffstat (limited to 'addons/web/static/tests/views/graph_tests.js')
-rw-r--r--addons/web/static/tests/views/graph_tests.js54
1 files changed, 48 insertions, 6 deletions
diff --git a/addons/web/static/tests/views/graph_tests.js b/addons/web/static/tests/views/graph_tests.js
index 253c98d706a..fda4c5cb190 100644
--- a/addons/web/static/tests/views/graph_tests.js
+++ b/addons/web/static/tests/views/graph_tests.js
@@ -97,16 +97,17 @@ QUnit.module('Views', {
product_id: {string: "Product", type: "many2one", relation: 'product', store: true},
color_id: {string: "Color", type: "many2one", relation: 'color'},
date: {string: "Date", type: 'date', store: true, sortable: true},
+ revenue: {string: "Revenue", type: 'integer', store: true},
},
records: [
- {id: 1, foo: 3, bar: true, product_id: 37, date: "2016-01-01"},
- {id: 2, foo: 53, bar: true, product_id: 37, color_id: 7, date: "2016-01-03"},
- {id: 3, foo: 2, bar: true, product_id: 37, date: "2016-03-04"},
- {id: 4, foo: 24, bar: false, product_id: 37, date: "2016-03-07"},
- {id: 5, foo: 4, bar: false, product_id: 41, date: "2016-05-01"},
+ {id: 1, foo: 3, bar: true, product_id: 37, date: "2016-01-01", revenue: 1},
+ {id: 2, foo: 53, bar: true, product_id: 37, color_id: 7, date: "2016-01-03", revenue: 2},
+ {id: 3, foo: 2, bar: true, product_id: 37, date: "2016-03-04", revenue: 3},
+ {id: 4, foo: 24, bar: false, product_id: 37, date: "2016-03-07", revenue: 4},
+ {id: 5, foo: 4, bar: false, product_id: 41, date: "2016-05-01", revenue: 5},
{id: 6, foo: 63, bar: false, product_id: 41},
{id: 7, foo: 42, bar: false, product_id: 41},
- {id: 8, foo: 48, bar: false, product_id: 41, date: "2016-04-01"},
+ {id: 8, foo: 48, bar: false, product_id: 41, date: "2016-04-01", revenue: 8},
]
},
product: {
@@ -1216,6 +1217,47 @@ QUnit.module('Views', {
graph.destroy();
});
+ QUnit.test('graph view without invisible attribute on field', async function (assert) {
+ assert.expect(4);
+
+ const graph = await createView({
+ View: GraphView,
+ model: "foo",
+ data: this.data,
+ arch: `<graph string="Partners"></graph>`,
+ });
+
+ await testUtils.dom.click(graph.$('.btn-group:first button'));
+ assert.containsN(graph, 'li.o_menu_item', 3,
+ "there should be three menu item in the measures dropdown (count, revenue and foo)");
+ assert.containsOnce(graph, 'li.o_menu_item a:contains("Revenue")');
+ assert.containsOnce(graph, 'li.o_menu_item a:contains("Foo")');
+ assert.containsOnce(graph, 'li.o_menu_item a:contains("Count")');
+
+ graph.destroy();
+ });
+
+ QUnit.test('graph view with invisible attribute on field', async function (assert) {
+ assert.expect(2);
+
+ const graph = await createView({
+ View: GraphView,
+ model: "foo",
+ data: this.data,
+ arch: `
+ <graph string="Partners">
+ <field name="revenue" invisible="1"/>
+ </graph>`,
+ });
+
+ await testUtils.dom.click(graph.$('.btn-group:first button'));
+ assert.containsN(graph, 'li.o_menu_item', 2,
+ "there should be only two menu item in the measures dropdown (count and foo)");
+ assert.containsNone(graph, 'li.o_menu_item a:contains("Revenue")');
+
+ graph.destroy();
+ });
+
QUnit.test('graph view sort by measure', async function (assert) {
assert.expect(18);