summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views
diff options
context:
space:
mode:
authorjerome hanke (jhk) <jhk@odoo.com>2020-03-17 10:49:00 +0000
committerjerome hanke (jhk) <jhk@odoo.com>2020-03-18 17:22:59 +0000
commite58db3ff5c787d087e5e8a4215a5d0a0c4becca0 (patch)
treeb55d3a0a4dd152256ef5573f3c74e1496c7c0f0f /addons/web/static/src/js/views
parent20e713bb2710a770a234dca1c5703699fcba8471 (diff)
[FIX] web: graph view ignores duplicate labels
Steps to reproduce: - install recruitment - go to recruitment > configuration > job positions > duplicate a job and keep the exact same name as the original > change the department - add any application to the newly created job position - go to recruitment > applications > all applications > select the graph view > group by job Previous behavior: you only see one of the two jop positions with the same name the graph view does not handle multiple labels with the same name and only keeps the latest values when rendering Current behavior: duplicate labels are suffixed to prevent the view from confusing them opw-2214284 closes odoo/odoo#47948 X-original-commit: a77086f8bcb4498361d1183ba8af3d0663cd031b Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com> Signed-off-by: mightyjol <jhk-odoo@users.noreply.github.com>
Diffstat (limited to 'addons/web/static/src/js/views')
-rw-r--r--addons/web/static/src/js/views/graph/graph_model.js1
-rw-r--r--addons/web/static/src/js/views/graph/graph_renderer.js13
2 files changed, 10 insertions, 4 deletions
diff --git a/addons/web/static/src/js/views/graph/graph_model.js b/addons/web/static/src/js/views/graph/graph_model.js
index 8dcb241ae9c..21614493e3c 100644
--- a/addons/web/static/src/js/views/graph/graph_model.js
+++ b/addons/web/static/src/js/views/graph/graph_model.js
@@ -242,6 +242,7 @@ return AbstractModel.extend({
value = 1;
}
self.chart.dataPoints.push({
+ resId: dataPt[self.chart.groupBy[0]] instanceof Array ? dataPt[self.chart.groupBy[0]][0] : -1,
count: count,
value: value,
labels: labels,
diff --git a/addons/web/static/src/js/views/graph/graph_renderer.js b/addons/web/static/src/js/views/graph/graph_renderer.js
index e83edbbbf04..cf6dba6e4c3 100644
--- a/addons/web/static/src/js/views/graph/graph_renderer.js
+++ b/addons/web/static/src/js/views/graph/graph_renderer.js
@@ -622,13 +622,19 @@ return AbstractRenderer.extend({
_prepareData: function (dataPoints) {
var self = this;
+ var labelMap = {};
var labels = dataPoints.reduce(
function (acc, dataPt) {
var label = self._getLabel(dataPt);
- var index = self._indexOf(acc, label);
- if (index === -1) {
+ var labelKey = dataPt.resId + ':' + JSON.stringify(label);
+ var index = labelMap[labelKey];
+ if (index === undefined) {
+ labelMap[labelKey] = dataPt.labelIndex = acc.length;
acc.push(label);
}
+ else{
+ dataPt.labelIndex = index;
+ }
return acc;
},
[]
@@ -650,8 +656,7 @@ return AbstractRenderer.extend({
if (!(datasetLabel in acc)) {
acc[datasetLabel] = newDataset(datasetLabel, dataPt.originIndex);
}
- var label = self._getLabel(dataPt);
- var labelIndex = self._indexOf(labels, label);
+ var labelIndex = dataPt.labelIndex;
acc[datasetLabel].data[labelIndex] = dataPt.value;
return acc;
},