From 0236ac510bbb58f5630a4249103ecf509160dbc7 Mon Sep 17 00:00:00 2001 From: David Monjoie Date: Wed, 21 Jun 2017 14:10:20 +0200 Subject: [PATCH] [FIX] web: update buttons in editable list view when no changes When I introduced this line in 374295b, I was working on the form view and didn't realize I would be breaking the editable list view. The _setMode function only updates the buttons when given the id of a record. Since I was working on a form view at the time, I didn't need to give a recordID to make it work since the default ID of a form view is the id of the record itself. However, in editable list view, the id of the view is a list of ids, so the buttons would not be updated in this case. --- .../web/static/src/js/views/basic/basic_controller.js | 2 +- addons/web/static/tests/views/list_tests.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js index 5024a67677e..67a4fa504d8 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -423,7 +423,7 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { }); if (!options.stayInEdit) { saveDef = saveDef.then(function (fieldNames) { - var def = fieldNames.length ? self._confirmSave(recordID) : self._setMode('readonly'); + var def = fieldNames.length ? self._confirmSave(recordID) : self._setMode('readonly', recordID); return def.then(function () { return fieldNames; }); diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js index bb38ba453a1..c39e6d2b1b0 100644 --- a/addons/web/static/tests/views/list_tests.js +++ b/addons/web/static/tests/views/list_tests.js @@ -136,7 +136,7 @@ QUnit.module('Views', { }); QUnit.test('simple editable rendering', function (assert) { - assert.expect(9); + assert.expect(12); var list = createView({ View: ListView, @@ -164,6 +164,15 @@ QUnit.module('Views', { "should have a visible save button"); assert.ok(list.$buttons.find('.o_list_button_discard').is(':visible'), "should have a visible discard button"); + + list.$buttons.find('.o_list_button_save').click(); + + assert.ok(list.$buttons.find('.o_list_button_add').is(':visible'), + "should have a visible Create button"); + assert.ok(!list.$buttons.find('.o_list_button_save').is(':visible'), + "should not have a visible save button"); + assert.ok(!list.$buttons.find('.o_list_button_discard').is(':visible'), + "should not have a visible discard button"); list.destroy(); });