[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").
This commit is contained in:
Martin Geubelle
2017-08-17 16:08:07 +02:00
parent 23ddb3ce63
commit cd0ba4234b
2 changed files with 31 additions and 1 deletions
@@ -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);
@@ -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':
'<tree string="Partner" editable="bottom">' +
'<field name="display_name"/>' +
'<field name="foo"/>' +
'</tree>',
'partner,false,search':
'<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();
});
});
});
});