From 840ab92bb4f1628b4235c4dec217b7201f3c3c82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20D=2E=20D=C3=ADaz?= Date: Thu, 7 Oct 2021 19:43:13 +0200 Subject: [PATCH] [FIX] web_time_range_menu_custom: Mix custom and 'no custom' periods Steps to reproduce: - Go to pivot view - Select a custom time range - Select a predefined comparison period (Ex. Previous Period) Now you see that the comparison period is not being applied. After this commit the comparison period is applied correctly. TT29249 --- web_time_range_menu_custom/__manifest__.py | 2 +- .../static/src/js/control_panel_model.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/web_time_range_menu_custom/__manifest__.py b/web_time_range_menu_custom/__manifest__.py index f1aa2ddcf..9cff15a64 100644 --- a/web_time_range_menu_custom/__manifest__.py +++ b/web_time_range_menu_custom/__manifest__.py @@ -2,7 +2,7 @@ { "name": "Web Time Range Menu Custom", - "version": "13.0.1.0.0", + "version": "13.0.1.0.1", "author": "Tecnativa, Odoo Community Association (OCA)", "license": "AGPL-3", "website": "https://github.com/OCA/web", diff --git a/web_time_range_menu_custom/static/src/js/control_panel_model.js b/web_time_range_menu_custom/static/src/js/control_panel_model.js index 16e268cec..7f11398e2 100644 --- a/web_time_range_menu_custom/static/src/js/control_panel_model.js +++ b/web_time_range_menu_custom/static/src/js/control_panel_model.js @@ -52,6 +52,21 @@ odoo.define("web_time_range_menu_custom.ControlPanelModel", function(require) { context.timeRangeMenuData.timeRange ); } + if (filter.comparisonTimeRangeId !== "custom_comparison_period") { + context.timeRangeMenuData.comparisonTimeRange = Domain.prototype.constructCustomDomain( + filter.fieldName, + filter.timeRangeId, + filter.fieldType, + filter.comparisonTimeRangeId, + filter.timeRangeCustom, + filter.comparisonTimeRangeCustom + ); + if (evaluation) { + context.timeRangeMenuData.comparisonTimeRange = Domain.prototype.stringToArray( + context.timeRangeMenuData.comparisonTimeRange + ); + } + } } if (filter.comparisonTimeRangeId === "custom_comparison_period") { context.timeRangeMenuData.comparisonTimeRange = Domain.prototype.constructCustomDomain(