diff --git a/addons/web/static/src/legacy/js/views/graph/graph_renderer.js b/addons/web/static/src/legacy/js/views/graph/graph_renderer.js index 895c6c0becd..7fb42dc0cc5 100644 --- a/addons/web/static/src/legacy/js/views/graph/graph_renderer.js +++ b/addons/web/static/src/legacy/js/views/graph/graph_renderer.js @@ -165,7 +165,7 @@ odoo.define("web/static/src/js/views/graph/graph_renderer", function (require) { dataset.pointBackgroundColor = dataset.borderColor; dataset.pointBorderColor = "rgba(0,0,0,0.2)"; } - if (data.datasets.length === 1) { + if (data.datasets.length === 1 && data.datasets[0].originIndex === 0) { const dataset = data.datasets[0]; dataset.fill = "origin"; dataset.backgroundColor = hexToRGBA(COLORS[0], 0.4); diff --git a/addons/web/static/src/views/graph/graph_renderer.js b/addons/web/static/src/views/graph/graph_renderer.js index 7f7e36ed675..089bc3e60b1 100644 --- a/addons/web/static/src/views/graph/graph_renderer.js +++ b/addons/web/static/src/views/graph/graph_renderer.js @@ -344,7 +344,7 @@ export class GraphRenderer extends Component { dataset.pointBackgroundColor = dataset.borderColor; dataset.pointBorderColor = "rgba(0,0,0,0.2)"; } - if (data.datasets.length === 1) { + if (data.datasets.length === 1 && data.datasets[0].originIndex === 0) { const dataset = data.datasets[0]; dataset.fill = "origin"; dataset.backgroundColor = hexToRGBA(getColor(0), 0.4); diff --git a/addons/web/static/tests/legacy/views/graph_tests.js b/addons/web/static/tests/legacy/views/graph_tests.js index 45276bfe8bc..460ac2b6a6a 100644 --- a/addons/web/static/tests/legacy/views/graph_tests.js +++ b/addons/web/static/tests/legacy/views/graph_tests.js @@ -459,6 +459,43 @@ QUnit.module('Views', { graph.destroy(); }); + QUnit.test('no filling color for period of comparison', async function (assert) { + assert.expect(1); + + const unpatchDate = patchDate(2020, 4, 19, 1, 0, 0); + + this.data.foo.records.forEach((r) => { + if (r.date) { + r.date = r.date.replace(/\d\d\d\d/, "2019"); + } + }); + + const graph = await createView({ + View: GraphView, + model: "foo", + data: this.data, + context: { search_default_date_filter: 1, }, + arch: '' + + '' + + '', + archs: { + 'foo,false,search': ` + + + + `, + }, + }); + + await cpHelpers.toggleComparisonMenu(graph.el); + await cpHelpers.toggleMenuItem(graph.el, 'Date: Previous period'); + + checkDatasets(assert, graph, ["data", "backgroundColor"], { data: [4, 2] }); + + unpatchDate(); + graph.destroy(); + }); + QUnit.test('no content helper after update', async function (assert) { assert.expect(6); diff --git a/addons/web/static/tests/views/graph_view_tests.js b/addons/web/static/tests/views/graph_view_tests.js index 64b8500e698..03719369423 100644 --- a/addons/web/static/tests/views/graph_view_tests.js +++ b/addons/web/static/tests/views/graph_view_tests.js @@ -3549,4 +3549,40 @@ QUnit.module("Views", (hooks) => { checkLabels(assert, graph, ['', '']); }); + + QUnit.test('no filling color for period of comparison', async function (assert) { + assert.expect(1); + + patchDate(2020, 4, 19, 1, 0, 0); + + serverData.models.foo.records.forEach((r) => { + if (r.date) { + r.date = r.date.replace(/\d\d\d\d/, "2019"); + } + }); + + const graph = await makeView({ + type: "graph", + resModel: "foo", + serverData, + context: { search_default_date_filter: 1, }, + arch: ` + + + + `, + searchViewArch: ` + + + + `, + }); + + await toggleComparisonMenu(graph); + await toggleMenuItem(graph, 'Date: Previous period'); + + checkDatasets(assert, graph, "backgroundColor", { + "backgroundColor": undefined, + }); + }); });