diff --git a/addons/board/static/src/js/add_to_board_menu.js b/addons/board/static/src/js/add_to_board_menu.js index fb6b469d5ab..ab56287b752 100644 --- a/addons/board/static/src/js/add_to_board_menu.js +++ b/addons/board/static/src/js/add_to_board_menu.js @@ -86,12 +86,18 @@ var AddToBoardMenu = Widget.extend({ var context = new Context(this.action.context); context.add(searchQuery.context); context.add({ - group_by: pyUtils.eval('groupbys', searchQuery.groupBys || []) + group_by: searchQuery.groupBy, + orderedBy: searchQuery.orderedBy, }); this.trigger_up('get_controller_query_params', { - callback: function (controllerContext) { - context.add(controllerContext); + callback: function (controllerQueryParams) { + var queryContext = controllerQueryParams.context; + var allContext = _.extend( + _.omit(controllerQueryParams, ['context']), + queryContext + ); + context.add(allContext); } }); diff --git a/addons/board/static/src/js/board_view.js b/addons/board/static/src/js/board_view.js index 4c1d989f54b..b12f4e9c338 100644 --- a/addons/board/static/src/js/board_view.js +++ b/addons/board/static/src/js/board_view.js @@ -272,6 +272,7 @@ var BoardRenderer = FormRenderer.extend({ context: context, domain: domain, groupBy: context.group_by || [], + orderedBy: context.orderedBy || [], }, withControlPanel: false, }); diff --git a/addons/board/static/tests/dashboard_tests.js b/addons/board/static/tests/dashboard_tests.js index 62dcb1f851c..cd3f47f73fe 100644 --- a/addons/board/static/tests/dashboard_tests.js +++ b/addons/board/static/tests/dashboard_tests.js @@ -109,7 +109,7 @@ QUnit.test('display the no content helper', function (assert) { }); QUnit.test('basic functionality, with one sub action', function (assert) { - assert.expect(25); + assert.expect(26); var form = createView({ View: BoardView, @@ -118,7 +118,7 @@ QUnit.test('basic functionality, with one sub action', function (assert) { arch: '
', @@ -132,6 +132,12 @@ QUnit.test('basic functionality, with one sub action', function (assert) { } if (route === '/web/dataset/search_read') { assert.deepEqual(args.domain, [['foo', '!=', 'False']], "the domain should be passed"); + assert.deepEqual(args.context.orderedBy, [{ + 'name': 'foo', + 'asc': true, + }], + 'orderedBy is present in the search read when specified on the custom action' + ); } if (route === '/web/view/edit_custom') { assert.step('edit custom'); @@ -686,7 +692,19 @@ QUnit.test('dashboard intercepts custom events triggered by sub controllers', fu }); QUnit.test('save actions to dashboard', function (assert) { - assert.expect(3); + assert.expect(6); + + testUtils.patch(ListController, { + getOwnedQueryParams: function () { + var result = this._super.apply(this, arguments); + result.context = { + 'fire': 'on the bayou', + } + return result; + } + }); + + this.data['partner'].fields.foo.sortable = true; var actionManager = createActionManager({ data: this.data, @@ -696,6 +714,16 @@ QUnit.test('save actions to dashboard', function (assert) { }, mockRPC: function (route, args) { if (route === '/board/add_to_dashboard') { + assert.deepEqual(args.context_to_save.group_by, ['foo'], + 'The group_by should have been saved'); + assert.deepEqual(args.context_to_save.orderedBy, + [{ + name: 'foo', + asc: true, + }], + 'The orderedBy should have been saved'); + assert.strictEqual(args.context_to_save.fire, 'on the bayou', + 'The context of a controller should be passed and flattened'); assert.strictEqual(args.action_id, 1, "should save the correct action"); assert.strictEqual(args.view_mode, 'list', @@ -716,12 +744,22 @@ QUnit.test('save actions to dashboard', function (assert) { assert.containsOnce(actionManager, '.o_list_view', "should display the list view"); + // Sort the list + testUtils.dom.click($('.o_column_sortable')); + + // Group It + testUtils.dom.click($('.o_search_options .o_dropdown button:contains(Group By)')); + testUtils.dom.click($('.o_search_options .o_group_by_menu button')); + testUtils.dom.click($('.o_search_options .o_group_by_menu button.o_apply_group')); + // add this action to dashboard testUtils.dom.click($('.o_search_options .o_dropdown button:contains(Favorites)')); testUtils.dom.click($('.o_add_to_board.o_menu_header')); testUtils.fields.editInput($('input.o_add_to_board_input'), 'a name'); testUtils.dom.click($('.o_add_to_board_confirm_button')); + testUtils.unpatch(ListController); + actionManager.destroy(); });