diff options
| author | Julien Mougenot <jum@odoo.com> | 2020-08-10 12:10:01 +0000 |
|---|---|---|
| committer | Julien Mougenot <jum@odoo.com> | 2020-08-11 10:12:15 +0000 |
| commit | c00e76b67c424498e29c4a82f6536084c3539b13 (patch) | |
| tree | b22f0a573b4e09b9c73b6af53c435bfefd68adce /addons/web/static/src/js | |
| parent | 2f0bf44c7a1ef2354fa6a0b87b1f380fa161305b (diff) | |
[FIX] web: Filter with domain disables category counters
Before this commit, the search panel was subject to some inconsistencies
when dealing with a category having enabled counters and with a filter
defining a "domain" attribute. Indeed, the counters could be in an
incorrect state if the right filters/categories were not loaded first,
with no simple way in doing so.
The search panel being complex enough as it is, we decided to disable
all categories' counters in the presence of a filter having a "domain"
attribute regardless of said domain.
closes odoo/odoo#55734
X-original-commit: e78f777bd8ccb314b85451cbc8d1dd9109997d7a
Related: odoo/enterprise#12341
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/views/search_panel_model_extension.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/addons/web/static/src/js/views/search_panel_model_extension.js b/addons/web/static/src/js/views/search_panel_model_extension.js index a5103f97447..48466f8d9e7 100644 --- a/addons/web/static/src/js/views/search_panel_model_extension.js +++ b/addons/web/static/src/js/views/search_panel_model_extension.js @@ -410,6 +410,8 @@ odoo.define("web/static/src/js/views/search_panel_model_extension.js", function * @private */ _createSectionsFromArch() { + let hasCategoryWithCounters = false; + let hasFilterWithDomain = false; this.config.archNodes.forEach(({ attrs, tag }, index) => { if (tag !== "field" || attrs.invisible === "1") { return; @@ -444,13 +446,33 @@ odoo.define("web/static/src/js/views/search_panel_model_extension.js", function bold: true, parentId: false, }); + hasCategoryWithCounters = hasCategoryWithCounters || section.enableCounters; } else { section.domain = attrs.domain || "[]"; section.groupBy = attrs.groupby; section.icon = section.icon || "fa-filter"; + hasFilterWithDomain = hasFilterWithDomain || section.domain !== "[]"; } this.state.sections.set(section.id, section); }); + /** + * Category counters are automatically disabled if a filter domain is found + * to avoid inconsistencies with the counters. The underlying problem could + * actually be solved by reworking the search panel and the way the + * counters are computed, though this is not the current priority + * considering the time it would take, hence this quick "fix". + */ + if (hasCategoryWithCounters && hasFilterWithDomain) { + // If incompatibilities are found -> disables all category counters + for (const category of this.categories) { + category.enableCounters = false; + } + // ... and triggers a warning + console.warn( + "Warning: categories with counters are incompatible with filters having a domain attribute.", + "All category counters have been disabled to avoid inconsistencies.", + ); + } } /** |
