summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/control_panel
diff options
context:
space:
mode:
authorMohammed Shekha <msh@odoo.com>2020-02-21 10:32:14 +0000
committerMathieu Duckerts-Antoine <dam@odoo.com>2020-05-11 13:40:10 +0000
commitc28244e4b256c3858ea9fefa3a536907876737fa (patch)
treedb0998f9d66e72c7959d7661836ef13b33656a5b /addons/web/static/src/js/control_panel
parentc5886e110924427b88d0212c5483622a0b8fc8c9 (diff)
[FIX] web: do not use groupbys in views not groupable
Before this commit: A problem occurs with kanban views that are not groupable (i.e. for which searchMenuTypes does not contain 'groupBy'): if the action has a default groupby (set in Studio for instance) then it is still applied and causes crashes. That happens in the documents kanban view for instance. More generally, if a view is not groupable, some information on groupbys can appear in the interface (in a facet) while not used/useful for the view. After this commit: - if a kanban view is not groupable, a default groupby will never be applied. - if a view is not groupable, we ensures that - the search query generated in the control panel has groupBy = [], - groupbys cannot be represented in a facet. closes odoo/odoo#51041 X-original-commit: 91c80291e90127792623476d8997fd2a67569170 Signed-off-by: Damien Bouvy (dbo) <dbo@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/control_panel')
-rw-r--r--addons/web/static/src/js/control_panel/control_panel_model.js44
1 files changed, 30 insertions, 14 deletions
diff --git a/addons/web/static/src/js/control_panel/control_panel_model.js b/addons/web/static/src/js/control_panel/control_panel_model.js
index 93c9d225d9b..034c4cd22c7 100644
--- a/addons/web/static/src/js/control_panel/control_panel_model.js
+++ b/addons/web/static/src/js/control_panel/control_panel_model.js
@@ -346,22 +346,33 @@ odoo.define('web.ControlPanelModel', function (require) {
* @returns {Object[]}
*/
getFacets() {
+ const accept = type => {
+ if (type === 'groupBy' && !this.searchMenuTypes.includes('groupBy')) {
+ return false;
+ }
+ return true;
+ };
+
const groups = this._getGroups();
- return groups.map(group => {
+ const facets = [];
+ for (const group of groups) {
const { activities, type, id } = group;
- const facet = {
- groupId: id,
- separator: type === 'groupBy' ? ">" : this.env._t("or"),
- values: this._getFacetDescriptions(activities, type),
- };
- const icon = FACET_ICONS[type];
- if (icon) {
- facet.icon = icon;
- } else {
- facet.title = activities[0].filter.description;
+ if (accept(type)) {
+ const facet = {
+ groupId: id,
+ separator: type === 'groupBy' ? ">" : this.env._t("or"),
+ values: this._getFacetDescriptions(activities, type),
+ };
+ const icon = FACET_ICONS[type];
+ if (icon) {
+ facet.icon = icon;
+ } else {
+ facet.title = activities[0].filter.description;
+ }
+ facets.push(facet);
}
- return facet;
- });
+ }
+ return facets;
}
/**
@@ -400,9 +411,14 @@ odoo.define('web.ControlPanelModel', function (require) {
const query = {
context: this._getContext(groups),
domain: this._getDomain(groups, requireEvaluation),
- groupBy: this._getGroupBy(groups),
orderedBy: this._getOrderedBy(groups)
};
+ if (this.searchMenuTypes.includes('groupBy')) {
+ const groupBy = this._getGroupBy(groups);
+ query.groupBy = groupBy;
+ } else {
+ query.groupBy = [];
+ }
if (this.searchMenuTypes.includes('timeRange')) {
const timeRanges = this._getTimeRanges(requireEvaluation);
query.timeRanges = timeRanges || {};