From c536b369d362e41f36b133f2b3646ba4ee4d8f4d Mon Sep 17 00:00:00 2001 From: Priyanka Kakadiya Date: Mon, 2 Sep 2019 09:03:19 +0000 Subject: [PATCH] [FIX] web: visible studio hooks in listview MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, there are no hooks when dragging a field over an editable listview. This was caused by wrong computation of column width in studio mode. This commit isolate the computation of column width, so that studio can override it and make the correct computation. Task-Id 2057829 closes odoo/odoo#36959 Signed-off-by: Alexandre Kühn (aku) Co-authored-by: Mohammed Shekha --- .../js/views/list/list_editable_renderer.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/addons/web/static/src/js/views/list/list_editable_renderer.js b/addons/web/static/src/js/views/list/list_editable_renderer.js index 70ea31aab01..1f7bf20b79c 100644 --- a/addons/web/static/src/js/views/list/list_editable_renderer.js +++ b/addons/web/static/src/js/views/list/list_editable_renderer.js @@ -640,6 +640,18 @@ ListRenderer.include({ } return $borderDataRow; }, + /** + * Compute the sum of the weights for each columns, excluding + * those with an absolute width. param `$thread` is useful for studio, in + * order to show column hooks. + * + * @private + * @param {jQuery} $thead + * @return {integer} + */ + _getColumnsTotalWidth($thead) { + return this.columns.reduce((acc, column) => acc + (column.attrs.relativeWidth || 0), 0); + }, /** * Returns the width of a column according the 'width' attribute set in the * arch, the widget or the field type. A fixed width is harcoded for some @@ -1053,11 +1065,7 @@ ListRenderer.include({ if (!this.columnWidths) { if (!this._hasVisibleRecords(this.state)) { - // we compute the sum of the weights for each columns, excluding - // those with an absolute width. - var totalWidth = this.columns.reduce(function (acc, column) { - return acc + (column.attrs.relativeWidth || 0); - }, 0); + var totalWidth = this._getColumnsTotalWidth($thead); this.columns.forEach(function (column) { let width; if (column.attrs.absoluteWidth) {