diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-09-05 18:52:27 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-09-05 18:52:27 +0200 |
| commit | f19e6ce561b80d291cc97bf928c4b84b48ec0f59 (patch) | |
| tree | 7c5419b940876244f95d055682bbe19429ff4747 /addons/web/static/src/js/views/pivot | |
| parent | 7700bd172f790858fb4cb9e64b90c9c77d9e5b0a (diff) | |
| parent | 213759b03e5466f119f52a557d7feefb9d477267 (diff) | |
[MERGE] forward port branch 11.0 up to 213759b03e5
Diffstat (limited to 'addons/web/static/src/js/views/pivot')
| -rw-r--r-- | addons/web/static/src/js/views/pivot/pivot_renderer.js | 13 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/pivot/pivot_view.js | 7 |
2 files changed, 19 insertions, 1 deletions
diff --git a/addons/web/static/src/js/views/pivot/pivot_renderer.js b/addons/web/static/src/js/views/pivot/pivot_renderer.js index b5648d358a9..390ccfed6e1 100644 --- a/addons/web/static/src/js/views/pivot/pivot_renderer.js +++ b/addons/web/static/src/js/views/pivot/pivot_renderer.js @@ -14,6 +14,16 @@ var PivotRenderer = AbstractRenderer.extend({ 'hover td': '_onTdHover', }), + /** + * @override + * @param {Object} [params.widgets] mapping (fieldName -> widget) used to + * format the cells + */ + init: function (parent, state, params) { + this._super.apply(this, arguments); + this.fieldWidgets = params.widgets || {}; + }, + //-------------------------------------------------------------------------- // Private //-------------------------------------------------------------------------- @@ -141,7 +151,8 @@ var PivotRenderer = AbstractRenderer.extend({ if (value !== undefined) { name = this.state.measures[j % nbrMeasures]; measure = this.state.fields[name]; - value = field_utils.format[measureTypes[j % nbrMeasures]](value, measure); + var formatter = this.fieldWidgets[name] || measureTypes[j % nbrMeasures]; + value = field_utils.format[formatter](value, measure); } $cell = $('<td>') .data('id', rows[i].id) diff --git a/addons/web/static/src/js/views/pivot/pivot_view.js b/addons/web/static/src/js/views/pivot/pivot_view.js index e0b232b6310..aa12a3324a7 100644 --- a/addons/web/static/src/js/views/pivot/pivot_view.js +++ b/addons/web/static/src/js/views/pivot/pivot_view.js @@ -43,6 +43,7 @@ var PivotView = AbstractView.extend({ var measures = {}; var groupableFields = {}; + var widgets = {}; this.fields.__count = {string: _t("Count"), type: "integer"}; _.each(this.fields, function (field, name) { @@ -64,6 +65,10 @@ var PivotView = AbstractView.extend({ name += ':' + field.attrs.interval; } + if (field.attrs.widget) { + widgets[name] = field.attrs.widget; + } + // add active measures to the measure list. This is very rarely // necessary, but it can be useful if one is working with a // functional field non stored, but in a model with an overrided @@ -94,6 +99,8 @@ var PivotView = AbstractView.extend({ this.loadParams.rowGroupBys = rowGroupBys; this.loadParams.fields = this.fields; + this.rendererParams.widgets = widgets; + this.controllerParams.title = params.title || this.arch.attrs.string || _t("Untitled"); this.controllerParams.enableLinking = !this.arch.attrs.disable_linking; this.controllerParams.measures = measures; |
