From 4a155bbede670bceb28c1e2ee03fa7a3da2f1493 Mon Sep 17 00:00:00 2001 From: Benoit Socias Date: Fri, 3 Feb 2023 08:01:06 +0000 Subject: [PATCH] [FIX] website: not fail when no dynamic filter is defined Since [1] when only website is installed, dropping a dynamic snippet produces an error because no dynamic filter is defined and it tries to specify one selected by default. This commit avoids setting a default filter when there is none. It did work in 15.0 because the log was inside `_renderDynamicFiltersSelector` which contained an `if (dynamicFilters.length > 0)` that avoided the problem. In [2], when most of that logic was moved from the render method to the fetch method, that condition was lost. Steps to reproduce: - Install website only - Go to debug mode - Drop a "Dynamic Snippet" or a "Dynamic Carousel" => Traceback appears because there cannot be a default filter when there is no filter. [1]: https://github.com/odoo/odoo/commit/3355dc16235355fe51e894f14e275210464608c6 [2]: https://github.com/odoo/odoo/commit/9e0b398fe608e716835260c5f9923f933d723f8e opw-3166634 closes odoo/odoo#114068 X-original-commit: 8e23f08b1470ec5fe47a4459c4d3a8ad314c43b0 Signed-off-by: Quentin Smetz (qsm) --- .../website/static/src/snippets/s_dynamic_snippet/options.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/website/static/src/snippets/s_dynamic_snippet/options.js b/addons/website/static/src/snippets/s_dynamic_snippet/options.js index 284b97f17a8..7b52e1d936c 100644 --- a/addons/website/static/src/snippets/s_dynamic_snippet/options.js +++ b/addons/website/static/src/snippets/s_dynamic_snippet/options.js @@ -154,6 +154,10 @@ const dynamicSnippetOptions = options.Class.extend({ model_name: this.modelNameFilter, search_domain: this.contextualFilterDomain, }}); + if (!dynamicFilters.length) { + // Additional modules are needed for dynamic filters to be defined. + return; + } for (let index in dynamicFilters) { this.dynamicFilters[dynamicFilters[index].id] = dynamicFilters[index]; }