summaryrefslogtreecommitdiff
path: root/addons/web
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2015-05-13 15:57:20 +0200
committerNicolas Lempereur <nle@odoo.com>2015-05-21 12:27:32 +0200
commit5cff8fbb7c70a372cb5116c2fb98fd622c4d4358 (patch)
treee982c711bcd4179f5341a7819286af3fa366858d /addons/web
parent4a0241d6f6920cdded62db2a3406b40d780a6287 (diff)
[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
Diffstat (limited to 'addons/web')
-rw-r--r--addons/web/static/src/js/view_pivot.js13
1 files changed, 12 insertions, 1 deletions
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,