summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/pivot/pivot_controller.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2017-06-13 09:35:30 +0200
committerAaron Bohy <aab@odoo.com>2017-06-14 10:15:37 +0200
commit70624772b2dd6a885a9cc8578e0e451063e18ad4 (patch)
treed7598b20b35fad8339f6dfc8cae7c86b99cbcb99 /addons/web/static/src/js/views/pivot/pivot_controller.js
parentbc415bd137a3b800568ff755c3168f9468c5608a (diff)
[FIX] web: Pivot: allow to click on a cell
Before this rev., when the user clicked on a data cell of a pivot view, it crashed. This was due to several problems, fixed by this commit.
Diffstat (limited to 'addons/web/static/src/js/views/pivot/pivot_controller.js')
-rw-r--r--addons/web/static/src/js/views/pivot/pivot_controller.js34
1 files changed, 13 insertions, 21 deletions
diff --git a/addons/web/static/src/js/views/pivot/pivot_controller.js b/addons/web/static/src/js/views/pivot/pivot_controller.js
index fb175aa1934..78640a97124 100644
--- a/addons/web/static/src/js/views/pivot/pivot_controller.js
+++ b/addons/web/static/src/js/views/pivot/pivot_controller.js
@@ -45,13 +45,15 @@ var PivotController = AbstractController.extend({
this.groupableFields = params.groupableFields;
this.title = params.title;
this.enableLinking = params.enableLinking;
+ // views to use in the action triggered when a data cell is clicked
+ this.views = params.views;
this.lastHeaderSelected = null;
},
/**
* @override
*/
start: function () {
- this.$el.toggleClass('o_enableLinking', this.enableLinking);
+ this.$el.toggleClass('o_enable_linking', this.enableLinking);
this.$fieldSelection = this.$('.o_field_selection');
core.bus.on('click', this, function () {
this.$fieldSelection.empty();
@@ -253,33 +255,23 @@ var PivotController = AbstractController.extend({
!this.enableLinking) {
return;
}
- var row_id = $target.data('id');
- var col_id = $target.data('col_id');
var state = this.model.get(this.handle);
- var row_domain = state.data.headers[row_id].domain;
- var col_domain = state.data.headers[col_id].domain;
- var context = _.omit(_.clone(state.context), 'group_by');
-
- function _find_view_info (views, view_type) {
- return _.find(views, function (view) {
- return view[1] === view_type;
- }) || [false, view_type];
- }
- var views = [
- _find_view_info(this.options.action.views, "list"),
- _find_view_info(this.options.action.views, "form"),
- ];
+ var colDomain = this.model.getHeader($target.data('col_id')).domain;
+ var rowDomain = this.model.getHeader($target.data('id')).domain;
+ var context = _.omit(state.context, function (val, key) {
+ return key === 'group_by' || _.str.startsWith(key, 'search_default_');
+ });
this.do_action({
type: 'ir.actions.act_window',
name: this.title,
- res_model: this.model,
- views: views,
- view_type : "list",
- view_mode : "list",
+ res_model: this.modelName,
+ views: this.views,
+ view_type: 'list',
+ view_mode: 'list',
target: 'current',
context: context,
- domain: state.domain.concat(row_domain, col_domain),
+ domain: state.domain.concat(rowDomain, colDomain),
});
},
/**