From 9bcc0498c0f4c174d45c8f58ae913767cab26145 Mon Sep 17 00:00:00 2001 From: Priyanka Kakadiya Date: Fri, 19 Apr 2019 06:33:40 +0000 Subject: [PATCH] [FIX] web: add test for the fix update buttons in editable list The test for the fix in 5adb6b62d22c49261d5b1aaeb1e9f15e40c074ae can only be implemented in 12.1 because that is the version that contains the createActionManager helper Task-1967278 closes odoo/odoo#32817 Signed-off-by: VincentSchippefilt --- .../src/js/views/list/list_controller.js | 5 ++- addons/web/static/tests/views/list_tests.js | 42 +++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/views/list/list_controller.js b/addons/web/static/src/js/views/list/list_controller.js index dfa7d272a49..c8dd6a86771 100644 --- a/addons/web/static/src/js/views/list/list_controller.js +++ b/addons/web/static/src/js/views/list/list_controller.js @@ -376,8 +376,9 @@ var ListController = BasicController.extend({ * @returns {Deferred} */ _update: function () { - this._toggleSidebar(); - return this._super.apply(this, arguments); + return this._super.apply(this, arguments) + .then(this._toggleSidebar.bind(this)) + .then(this._updateButtons.bind(this, 'readonly')); }, /** * This helper simply makes sure that the control panel buttons matches the diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js index 18dd10c52a6..cf41de943ba 100644 --- a/addons/web/static/tests/views/list_tests.js +++ b/addons/web/static/tests/views/list_tests.js @@ -14,6 +14,7 @@ var testUtilsDom = require('web.test_utils_dom'); var widgetRegistry = require('web.widget_registry'); var Widget = require('web.Widget'); +var createActionManager = testUtils.createActionManager; var createView = testUtils.createView; QUnit.module('Views', { @@ -840,6 +841,47 @@ QUnit.module('Views', { list.destroy(); }); + QUnit.test('editable list view: check that controlpanel buttons are updating when groupby applied', function (assert) { + assert.expect(4); + + this.data.foo.fields.foo = {string: "Foo", type: "char", required:true}; + + var actionManager = createActionManager({ + actions: [{ + id: 11, + name: 'Partners Action 11', + res_model: 'foo', + type: 'ir.actions.act_window', + views: [[3, 'list']], + search_view_id: [9, 'search'], + }], + archs: { + 'foo,3,list': '', + + 'foo,9,search': ''+ + '' + + '', + }, + data: this.data, + }); + + actionManager.doAction(11); + testUtils.dom.click(actionManager.$('.o_list_button_add')); + + assert.isNotVisible(actionManager.$('.o_list_button_add'), + "create button should be invisible"); + assert.isVisible(actionManager.$('.o_list_button_save'), "save button should be visible"); + + testUtils.dom.click(actionManager.$('.o_dropdown_toggler_btn:contains("Group By")')); + testUtils.dom.click(actionManager.$('.o_group_by_menu .o_menu_item a:contains("candle")')); + + assert.isVisible(actionManager.$('.o_list_button_add'), "create button should be invisible"); + assert.isNotVisible(actionManager.$('.o_list_button_save'), + "save button should be invisible after applying groupby"); + + actionManager.destroy(); + }); + QUnit.test('selection changes are triggered correctly', function (assert) { assert.expect(8);