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 a0658a71ee1..e88900cbc57 100644 --- a/addons/web_editor/static/src/js/editor/snippets.options.js +++ b/addons/web_editor/static/src/js/editor/snippets.options.js @@ -1963,12 +1963,21 @@ const ListUserValueWidget = UserValueWidget.extend({ if (this.createWidget) { const selectedIds = currentValues.map(({ id }) => id) .filter(id => typeof id === 'number'); - const selectedIdsDomain = ['id', 'not in', selectedIds]; + // Note: it's important to simplify the domain at its maximum as the + // rpc using it are cached. Similar domains should be written the + // same way for the cache to work. + const selectedIdsDomain = selectedIds.length ? ['id', 'not in', selectedIds] : null; const selectedIdsDomainIndex = this.createWidget.options.domain.findIndex(domain => domain[0] === 'id' && domain[1] === 'not in'); if (selectedIdsDomainIndex > -1) { - this.createWidget.options.domain[selectedIdsDomainIndex] = selectedIdsDomain; + if (selectedIdsDomain) { + this.createWidget.options.domain[selectedIdsDomainIndex] = selectedIdsDomain; + } else { + this.createWidget.options.domain.splice(selectedIdsDomainIndex, 1); + } } else { - this.createWidget.options.domain = [...this.createWidget.options.domain, selectedIdsDomain]; + if (selectedIdsDomain) { + this.createWidget.options.domain = [...this.createWidget.options.domain, selectedIdsDomain]; + } } this.createWidget.setValue(''); this.createWidget.inputEl.value = '';