[FIX] web_editor: prevent setting values of non-activable methods

closes odoo/odoo#41404

X-original-commit: 6af602fa676db19260a828a3cfd0befe3ba1ef4e
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
qsm-odoo
2019-12-05 10:59:48 +00:00
parent b62b686066
commit d7f4289166
@@ -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>|string}
* @returns {Promise<string|undefined>|string|undefined}
*/
_computeWidgetState: async function (methodName, params) {
switch (methodName) {