From d7f4289166b3d3d2f52b3769fbddad5f8a964907 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Wed, 4 Dec 2019 18:47:44 +0000 Subject: [PATCH] [FIX] web_editor: prevent setting values of non-activable methods closes odoo/odoo#41404 X-original-commit: 6af602fa676db19260a828a3cfd0befe3ba1ef4e Signed-off-by: Quentin Smetz (qsm) --- addons/web_editor/static/src/js/editor/snippets.options.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/editor/snippets.options.js b/addons/web_editor/static/src/js/editor/snippets.options.js index ca8ef46b4d9..19e69958884 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -1331,6 +1331,9 @@ const SnippetOptionWidget = Widget.extend({ const methodsNames = widget.getMethodsNames(); const proms = methodsNames.map(async methodName => { const value = await this._computeWidgetState(methodName, widget.getMethodsParams(methodName)); + if (value === undefined) { + return; + } const normalizedValue = this._normalizeWidgetValue(value); widget.setValue(normalizedValue, methodName); }); @@ -1351,10 +1354,12 @@ const SnippetOptionWidget = Widget.extend({ * Returns the string value that should be hold by the widget which is * related to the given method name. * + * If the value is irrelevant for a method, it must return undefined. + * * @private * @param {string} methodName * @param {Object} params - * @returns {Promise|string} + * @returns {Promise|string|undefined} */ _computeWidgetState: async function (methodName, params) { switch (methodName) {