From cd0ba4234bfa8ce3156d71f823d29d53b763a418 Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Wed, 16 Aug 2017 17:26:19 +0200 Subject: [PATCH] [FIX] web: avoid SelectCreateDialog editable list view As its name indicates, the SelectCreateDialog is meant to select and create, not edit. If the view is editable, clicking on an element will edit it instead of selecting it. For this reason, the view is set in `readonly` even if the view arch uses the attribute `editable`. Before this rev., you couldn't select a "Close Reason" when closing a subscription (in "Search More"). --- .../web/static/src/js/views/view_dialogs.js | 1 + .../static/tests/views/view_dialogs_tests.js | 31 ++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/views/view_dialogs.js b/addons/web/static/src/js/views/view_dialogs.js index d38400c2e84..558fefd03ac 100644 --- a/addons/web/static/src/js/views/view_dialogs.js +++ b/addons/web/static/src/js/views/view_dialogs.js @@ -343,6 +343,7 @@ var SelectCreateDialog = ViewDialog.extend({ groupBy: searchResult.groupBy, modelName: self.dataset.model, hasSelectors: !self.options.disable_multiple_selection, + readonly: true, }, self.options.list_view_options)); listView.setController(SelectCreateListController); return listView.getController(self); diff --git a/addons/web/static/tests/views/view_dialogs_tests.js b/addons/web/static/tests/views/view_dialogs_tests.js index 8c46d8fff46..43bf4ee6694 100644 --- a/addons/web/static/tests/views/view_dialogs_tests.js +++ b/addons/web/static/tests/views/view_dialogs_tests.js @@ -140,6 +140,35 @@ QUnit.module('Views', { dialog.destroy(); }); + QUnit.test('SelectCreateDialog list view in readonly', function (assert) { + assert.expect(1); + + var parent = createParent({ + data: this.data, + archs: { + 'partner,false,list': + '' + + '' + + '' + + '', + 'partner,false,search': + '' + }, + }); + + var dialog = new dialogs.SelectCreateDialog(parent, { + res_model: 'partner', + }).open(); + + // click on the first row to see if the list is editable + dialog.$('.o_list_view tbody tr:first td:not(.o_list_record_selector):first').click(); + + assert.equal(dialog.$('.o_list_view tbody tr:first td:not(.o_list_record_selector):first input').length, 0, + "list view should not be editable in a SelectCreateDialog"); + + dialog.destroy(); + }); + }); -}); \ No newline at end of file +});