[IMP] web: scope list table selection

Prior to this commit, the list_editable_renderer was grabbing the first
table in the DOM. This made it so extending list views with another table
could cause the new table to resize unexpectedly when changing the column
width of the list view generated table (i.e. o_list_table).

While this double table situation may not arise very often, it directly
hindered task: 2198420 and may hinder other customized view tasks.

Related to task: 2198420
("Requests for Quotations KPI's" subsection)

closes odoo/odoo#46654

Related: odoo/upgrade#877
Related: odoo/enterprise#8945
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
This commit is contained in:
Tiffany Chang (tic)
2020-03-31 10:31:35 +00:00
parent fe41c92771
commit 69e5f59005
@@ -663,7 +663,7 @@ ListRenderer.include({
if (!thElements.length) {
return;
}
const table = this.el.getElementsByTagName('table')[0];
const table = this.el.getElementsByClassName('o_list_table')[0];
let columnWidths = this.columnWidths;
if (!columnWidths || !columnWidths.length) { // no column widths to restore
@@ -1228,7 +1228,7 @@ ListRenderer.include({
_renderView: function () {
this.currentRow = null;
return this._super.apply(this, arguments).then(() => {
const table = this.el.getElementsByTagName('table')[0];
const table = this.el.getElementsByClassName('o_list_table')[0];
if (table) {
table.classList.toggle('o_empty_list', !this._hasVisibleRecords(this.state));
this._freezeColumnWidths();
@@ -1341,7 +1341,7 @@ ListRenderer.include({
* overflow
*/
_squeezeTable: function () {
const table = this.el.getElementsByTagName('table')[0];
const table = this.el.getElementsByClassName('o_list_table')[0];
const thead = table.getElementsByTagName('thead')[0];
const thElements = [...thead.getElementsByTagName('th')];
const columnWidths = thElements.map(th => th.offsetWidth);
@@ -1684,7 +1684,7 @@ ListRenderer.include({
this.isResizing = true;
const table = this.el.getElementsByTagName('table')[0];
const table = this.el.getElementsByClassName('o_list_table')[0];
const th = ev.target.closest('th');
table.style.width = `${table.offsetWidth}px`;
const thPosition = [...th.parentNode.children].indexOf(th);