[FIX] web: duplicates header in pivot

For report with duplicated named headers, several columns could get
squashed together.

This fix check if a value is a duplicate or not, and if it is a
duplicates postfix an number allowing to differentiate the two headers
(for the human and the javascript).

closes #6722
opw-634771
This commit is contained in:
Nicolas Lempereur
2015-05-21 12:27:32 +02:00
parent 4a0241d6f6
commit 5cff8fbb7c
+12 -1
View File
@@ -56,6 +56,8 @@ instance.web.PivotView = instance.web.View.extend({
this.last_header_selected = null;
this.sorted_column = {};
this.numbering = {};
},
start: function () {
var self = this;
@@ -472,13 +474,22 @@ instance.web.PivotView = instance.web.View.extend({
},
sanitize_value: function (value, field) {
if (value === false) return _t("Undefined");
if (value instanceof Array) return value[1];
if (value instanceof Array) return this.get_numbered_value(value, field);
if (field && this.fields[field] && (this.fields[field].type === 'selection')) {
var selected = _.where(this.fields[field].selection, {0: value})[0];
return selected ? selected[1] : value;
}
return value;
},
get_numbered_value: function(value, field) {
var id= value[0];
var name= value[1]
this.numbering[field] = this.numbering[field] || {};
this.numbering[field][name] = this.numbering[field][name] || {};
var numbers = this.numbering[field][name];
numbers[id] = numbers[id] || _.size(numbers) + 1;
return name + (numbers[id] > 1 ? " (" + numbers[id] + ")" : "");
},
make_header: function (data_pt, root, i, j, parent_header) {
var attrs = data_pt.attributes,
value = attrs.value,