diff --git a/addons/web/static/src/views/list/list_renderer.js b/addons/web/static/src/views/list/list_renderer.js index 34586292319..da45ebb672a 100644 --- a/addons/web/static/src/views/list/list_renderer.js +++ b/addons/web/static/src/views/list/list_renderer.js @@ -203,7 +203,7 @@ export class ListRenderer extends Component { } const table = this.tableRef.el; - const headers = [...table.querySelectorAll("thead th")]; + const headers = [...table.querySelectorAll("thead th:not(.o_list_record_remove_header)")]; if (!this.columnWidths || !this.columnWidths.length) { // no column widths to restore @@ -333,6 +333,17 @@ export class ListRenderer extends Component { return this.props.list.fields; } + get nbCols() { + let nbCols = this.state.columns.length; + if (this.hasSelectors) { + nbCols++; + } + if (this.props.activeActions && this.props.activeActions.onDelete) { + nbCols++; + } + return nbCols; + } + canUseFormatter(column, record) { return ( !record.isInEdition && !column.widget && record.fields[column.name].type !== "boolean" diff --git a/addons/web/static/src/views/list/list_renderer.xml b/addons/web/static/src/views/list/list_renderer.xml index 6cadfaa080d..465f9a90630 100644 --- a/addons/web/static/src/views/list/list_renderer.xml +++ b/addons/web/static/src/views/list/list_renderer.xml @@ -75,7 +75,7 @@ - @@ -105,7 +105,7 @@ - ​ + ​ @@ -119,7 +119,7 @@ { } ); + QUnit.test("colspan of empty lines is correct in readonly and edit", async function (assert) { + serverData.models.foo.fields.foo_o2m = { + string: "Foo O2M", + type: "one2many", + relation: "foo", + }; + await makeView({ + type: "form", + resModel: "foo", + serverData, + resId: 1, + mode: "readonly", + arch: ` +
+ + + + + + + +
`, + }); + assert.strictEqual(target.querySelector("tbody td").getAttribute("colspan"), "1"); + await clickEdit(target); + // in edit mode, the delete action is available and the empty lines should cover that col + assert.strictEqual(target.querySelector("tbody td").getAttribute("colspan"), "2"); + }); + QUnit.test( "width of some fields should be hardcoded if no data, and list initially invisible", async function (assert) {