diff options
| author | Mathieu Duckerts-Antoine <dam@odoo.com> | 2020-04-21 18:18:57 +0000 |
|---|---|---|
| committer | Mathieu Duckerts-Antoine <dam@odoo.com> | 2020-04-28 14:57:58 +0000 |
| commit | 7b402c5e59282eb9100adede97e730cdc73da690 (patch) | |
| tree | c1bcdc9a90a25689f9dee5aa3f4ce840a4e98e5c /addons/web/static | |
| parent | 64ae832a8ae04ad86b7707e507b71ab612bce87e (diff) | |
[FIX] web: limit on search panel values
Before this commit, if a many2X field with a big comodel was added
in a search panel, the view using it would crash. For instance that
problem occured in the kanban view for hr.job, where res.users
appears as the comodel for the field user_id.
Now, we fix an arbitrary limit of 200 to the numbers of values to fetch
for each many2X fields in the search panel. This avoid the problem
mentionned above.
Furthermore, in case the limit is attained for a field used
as select="one", the values are displayed without being hierarchized.
Indeed the limit can leads to gaps in the knowledge of the hierarchy
and consequently to a bad representation of it.
Task ID: 2154668
closes odoo/odoo#50334
X-original-commit: 8d57153b34c04952a85f6642951cb2697016da84
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static')
| -rw-r--r-- | addons/web/static/src/js/views/search_panel.js | 16 | ||||
| -rw-r--r-- | addons/web/static/src/xml/kanban.xml | 7 |
2 files changed, 22 insertions, 1 deletions
diff --git a/addons/web/static/src/js/views/search_panel.js b/addons/web/static/src/js/views/search_panel.js index 377eb723621..6a1d8381fb7 100644 --- a/addons/web/static/src/js/views/search_panel.js +++ b/addons/web/static/src/js/views/search_panel.js @@ -19,6 +19,8 @@ var qweb = core.qweb; // in the arch) var defaultViewTypes = ['kanban', 'tree']; +const SEARCH_PANEL_LIMIT = 200; + /** * Given a <searchpanel> arch node, iterate over its children to generate the * description of each section (being either a category or a filter). @@ -279,7 +281,15 @@ var SearchPanel = Widget.extend({ */ _createCategoryTree: function (categoryId, values) { var category = this.categories[categoryId]; - var parentField = category.parentField; + + let parentField = category.parentField; + if (values.length === SEARCH_PANEL_LIMIT) { + category.limitAttained = true; + if (parentField) { + // we do not hierarchize values + parentField = false; + } + } category.values = {}; _.each(values, function (value) { @@ -324,6 +334,10 @@ var SearchPanel = Widget.extend({ _createFilterTree: function (filterId, values) { var filter = this.filters[filterId]; + if (values.length === SEARCH_PANEL_LIMIT) { + filter.limitAttained = true; + } + // restore checked property values.forEach(function (value) { var oldValue = filter.values && filter.values[value.id]; diff --git a/addons/web/static/src/xml/kanban.xml b/addons/web/static/src/xml/kanban.xml index 48d95dd00b3..e4ef2393e3f 100644 --- a/addons/web/static/src/xml/kanban.xml +++ b/addons/web/static/src/xml/kanban.xml @@ -236,6 +236,10 @@ <t t-set="values" t-value="category.rootIds"/> </t> </ul> + <div t-if="category.limitAttained" class="alert alert-warning"> + <span>For performance reasons, only 200 values were fetched. Some values might be missing.</span> + <span t-if="category.parentField">The values have not been hierarchized.</span> + </div> </section> </t> <t t-name="SearchPanel.CategoryValues"> @@ -271,6 +275,9 @@ <t t-set="values" t-value="filter.values"/> </t> </ul> + <div t-if="filter.limitAttained" class="alert alert-warning"> + <span>For performance reasons, only 200 values were fetched. Some values might be missing.</span> + </div> </section> </t> <t t-name="SearchPanel.FilterGroups"> |
