diff --git a/addons/board/static/src/board_action.js b/addons/board/static/src/board_action.js index edf4663d14b..aca3ebb2346 100644 --- a/addons/board/static/src/board_action.js +++ b/addons/board/static/src/board_action.js @@ -50,7 +50,7 @@ export class BoardAction extends Component { this.viewProps.domain = action.domain; } if (viewMode === "list") { - this.viewProps.hasSelectors = false; + this.viewProps.allowSelectors = false; } }); } diff --git a/addons/web/static/src/views/kanban/kanban_controller.js b/addons/web/static/src/views/kanban/kanban_controller.js index 2b96c845534..981ff92f1d4 100644 --- a/addons/web/static/src/views/kanban/kanban_controller.js +++ b/addons/web/static/src/views/kanban/kanban_controller.js @@ -112,7 +112,6 @@ KanbanController.props = { defaultGroupBy: { validate: (dgb) => !dgb || typeof dgb === "string", optional: true }, editable: { type: Boolean, optional: true }, forceGlobalClick: { type: Boolean, optional: true }, - hasSelectors: { type: Boolean, optional: true }, onSelectionChanged: { type: Function, optional: true }, showButtons: { type: Boolean, optional: true }, Model: Function, diff --git a/addons/web/static/src/views/list/list_controller.js b/addons/web/static/src/views/list/list_controller.js index fb985f67b13..e2b8655e1b7 100644 --- a/addons/web/static/src/views/list/list_controller.js +++ b/addons/web/static/src/views/list/list_controller.js @@ -439,8 +439,8 @@ ListController.template = `web.ListView`; ListController.components = { ActionMenus, ListViewHeaderButton, Layout, ViewButton }; ListController.props = { ...standardViewProps, + allowSelectors: { type: Boolean, optional: true }, editable: { type: Boolean, optional: true }, - hasSelectors: { type: Boolean, optional: true }, onSelectionChanged: { type: Function, optional: true }, showButtons: { type: Boolean, optional: true }, Model: Function, @@ -449,9 +449,9 @@ ListController.props = { archInfo: Object, }; ListController.defaultProps = { + allowSelectors: true, createRecord: () => {}, editable: true, - hasSelectors: true, selectRecord: () => {}, showButtons: true, }; diff --git a/addons/web/static/src/views/list/list_controller.xml b/addons/web/static/src/views/list/list_controller.xml index 262c7913cfa..5e0020739e3 100644 --- a/addons/web/static/src/views/list/list_controller.xml +++ b/addons/web/static/src/views/list/list_controller.xml @@ -25,7 +25,7 @@ resModel="model.root.resModel"/> - + diff --git a/addons/web/static/src/views/list/list_renderer.js b/addons/web/static/src/views/list/list_renderer.js index 3f84325a616..b755eebd1f8 100644 --- a/addons/web/static/src/views/list/list_renderer.js +++ b/addons/web/static/src/views/list/list_renderer.js @@ -189,7 +189,7 @@ export class ListRenderer extends Component { } get hasSelectors() { - return this.props.hasSelectors && !this.env.isSmall; + return this.props.allowSelectors && !this.env.isSmall; } add(params) { @@ -1680,6 +1680,9 @@ export class ListRenderer extends Component { } onRowTouchStart(record, ev) { + if (!this.props.allowSelectors) { + return; + } if (this.props.list.selection.length) { // in selection mode, only selection is allowed. ev.preventDefault(); @@ -1719,7 +1722,7 @@ ListRenderer.props = [ "openRecord", "onAdd?", "cycleOnTab?", - "hasSelectors?", + "allowSelectors?", "editable?", "noContentHelp?", "nestedKeyOptionalFieldsData?", diff --git a/addons/web/static/src/views/view_dialogs/select_create_dialog.js b/addons/web/static/src/views/view_dialogs/select_create_dialog.js index 356ff8c4473..f99047f9451 100644 --- a/addons/web/static/src/views/view_dialogs/select_create_dialog.js +++ b/addons/web/static/src/views/view_dialogs/select_create_dialog.js @@ -25,16 +25,20 @@ export class SelectCreateDialog extends Component { } get viewProps() { - return { + const type = this.env.isSmall ? "kanban" : "list"; + const props = { ...this.baseViewProps, context: this.props.context, domain: this.props.domain, dynamicFilters: this.props.dynamicFilters, - hasSelectors: this.props.multiSelect, resModel: this.props.resModel, searchViewId: this.props.searchViewId, - type: this.env.isSmall ? "kanban" : "list", + type, }; + if (type === "list") { + props.allowSelectors = this.props.multiSelect; + } + return props; } async select(resIds) { diff --git a/addons/web/static/tests/views/fields/one2many_field_tests.js b/addons/web/static/tests/views/fields/one2many_field_tests.js index 9bd60c7a3c2..0910a211c25 100644 --- a/addons/web/static/tests/views/fields/one2many_field_tests.js +++ b/addons/web/static/tests/views/fields/one2many_field_tests.js @@ -12542,4 +12542,24 @@ QUnit.module("Fields", (hooks) => { await clickSave(target); assert.verifySteps(["write partner", "read partner"]); }); + + QUnit.test("can't select a record in a one2many", async function (assert) { + await makeView({ + type: "form", + resModel: "partner", + serverData, + arch: ` +
+ + + + + +
`, + resId: 1, + }); + + await triggerEvents(target, ".o_data_row", ["touchstart", "touchend"]); + assert.containsNone(target, ".o_data_row_selected"); + }); }); diff --git a/addons/web/static/tests/views/list_view_tests.js b/addons/web/static/tests/views/list_view_tests.js index 6c70921fb00..6cdf73f9fa4 100644 --- a/addons/web/static/tests/views/list_view_tests.js +++ b/addons/web/static/tests/views/list_view_tests.js @@ -1276,7 +1276,7 @@ QUnit.module("Views", (hooks) => { serverData, arch: '', groupBy: ["bar"], - hasSelectors: false, + allowSelectors: false, }); assert.containsOnce(target.querySelector(".o_group_header"), "th"); @@ -1303,7 +1303,7 @@ QUnit.module("Views", (hooks) => { serverData, arch: '', groupBy: ["bar"], - hasSelectors: false, + allowSelectors: false, }); assert.containsN(target.querySelector(".o_group_header"), "th", 2); @@ -1317,7 +1317,7 @@ QUnit.module("Views", (hooks) => { serverData, arch: '', groupBy: ["bar"], - hasSelectors: false, + allowSelectors: false, }); assert.containsN(target.querySelector(".o_group_header"), "th", 2); @@ -1331,7 +1331,7 @@ QUnit.module("Views", (hooks) => { serverData, arch: '', groupBy: ["bar"], - hasSelectors: true, + allowSelectors: true, }); assert.containsN(target.querySelector(".o_group_header"), "th", 2); @@ -1345,7 +1345,7 @@ QUnit.module("Views", (hooks) => { serverData, arch: '', groupBy: ["bar"], - hasSelectors: true, + allowSelectors: true, }); assert.containsN(target.querySelector(".o_group_header"), "th", 2);