From 5cff8fbb7c70a372cb5116c2fb98fd622c4d4358 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Wed, 13 May 2015 15:57:20 +0200 Subject: [PATCH] [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 --- addons/web/static/src/js/view_pivot.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/view_pivot.js b/addons/web/static/src/js/view_pivot.js index ae778b8dc0b..1d696e0114f 100644 --- a/addons/web/static/src/js/view_pivot.js +++ b/addons/web/static/src/js/view_pivot.js @@ -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,