diff options
| author | Aaron Bohy <aab@odoo.com> | 2017-03-16 11:22:46 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-04-11 19:44:38 +0200 |
| commit | 322b850ab6ed1d91a7ac44e4eef9ec3e8b02e26a (patch) | |
| tree | d7d2692b85b33ca27d78a53eab716a88db057c6e /addons/web | |
| parent | 378d6813ff03a428537b98bb7232c09ef4d957d5 (diff) | |
[FIX] web: KanbanModel: don't allow nested groups
Nested groups is only for list views. In kanban, only the first
grouping level is taken into account.
Diffstat (limited to 'addons/web')
| -rw-r--r-- | addons/web/static/src/js/views/kanban/kanban_model.js | 19 | ||||
| -rw-r--r-- | addons/web/static/test/views/kanban_model_tests.js | 30 |
2 files changed, 49 insertions, 0 deletions
diff --git a/addons/web/static/src/js/views/kanban/kanban_model.js b/addons/web/static/src/js/views/kanban/kanban_model.js index 2bfe117829d..c600ab48b1e 100644 --- a/addons/web/static/src/js/views/kanban/kanban_model.js +++ b/addons/web/static/src/js/views/kanban/kanban_model.js @@ -167,6 +167,25 @@ var KanbanModel = BasicModel.extend({ return parentID; }); }, + + //-------------------------------------------------------------------------- + // Private + //-------------------------------------------------------------------------- + + /** + * Ensures that there is no nested groups in Kanban (only the first grouping + * level is taken into account). + * + * @override + * @private + * @param {Object} list valid resource object + */ + _readGroup: function (list) { + if (list.groupedBy.length > 1) { + list.groupedBy = [list.groupedBy[0]]; + } + return this._super.apply(this, arguments); + }, }); return KanbanModel; diff --git a/addons/web/static/test/views/kanban_model_tests.js b/addons/web/static/test/views/kanban_model_tests.js index d3d6a913ea5..b6ef91aa75a 100644 --- a/addons/web/static/test/views/kanban_model_tests.js +++ b/addons/web/static/test/views/kanban_model_tests.js @@ -155,6 +155,36 @@ QUnit.module('Views', { }); }); + QUnit.test('kanban model does not allow nested groups', function (assert) { + assert.expect(2); + + var model = createModel({ + Model: KanbanModel, + data: this.data, + mockRPC: function (route, args) { + if (args.method === 'read_group') { + assert.deepEqual(args.kwargs.groupby, ['product_id'], + "the second level of groupBy should have been removed"); + } + return this._super.apply(this, arguments); + }, + }); + + var params = _.extend(this.params, { + groupedBy: ['product_id', 'qux'], + fieldNames: ['foo'], + }); + + model.load(params).then(function (resultID) { + var state = model.get(resultID); + + assert.deepEqual(state.groupedBy, ['product_id'], + "the second level of groupBy should have been removed"); + + model.destroy(); + }); + }); + }); }); |
