From bfffd2ee7c522d619f0bf8caebaa3c34320f3323 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Mon, 22 Apr 2024 14:28:52 +0200 Subject: [PATCH] [FIX] web: list: tolerate editable"1" (only in stable) A few x2many list embedded in form views have the "editable" attr set to "1". Normally, the valid values for this attribute are "top" and "bottom". Regular list views are validated, but not lists inside form views. When set to "1", some features of the model aren't enabled. For instance, when the current page is full and the user adds a record, the limit isn't temporarilly increased for the added record to be displayed on the current page, like it would be in editable="bottom" lists, so the user doesn't see the record he just added. The issue can be observed in the stock move form view for instance. This commit is only good for stable versions: we add a fallback on "bottom" s.t. if the editable attribute is set, it's always either "top" or "bottom". In master, we'll probably rethink the API. opw~3860903 closes odoo/odoo#162832 Signed-off-by: Lucas Perais (lpe) --- addons/web/static/src/views/list/list_arch_parser.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/views/list/list_arch_parser.js b/addons/web/static/src/views/list/list_arch_parser.js index e69a73b5fee..3a3662437d8 100644 --- a/addons/web/static/src/views/list/list_arch_parser.js +++ b/addons/web/static/src/views/list/list_arch_parser.js @@ -183,7 +183,15 @@ export class ListArchParser { treeAttr.activeActions = activeActions; treeAttr.className = xmlDoc.getAttribute("class") || null; - treeAttr.editable = xmlDoc.getAttribute("editable"); + let editableAttr = xmlDoc.getAttribute("editable"); + // FIXME: supported values for the editable attribute are normally "top"/"bottom". + // However, form views aren't validated, and a few x2many list have editable="1". + // In master, we'll throw to enforce valid values, but in 17, let's fallback on + // "bottom". + if (editableAttr && !["top", "bottom"].includes(editableAttr)) { + editableAttr = archParseBoolean(editableAttr) ? "bottom" : null; + } + treeAttr.editable = editableAttr; treeAttr.multiEdit = activeActions.edit ? archParseBoolean(node.getAttribute("multi_edit") || "") : false;