mirror of https://github.com/OCA/web.git
[IMP] web_time_range_menu_custom: black, isort, prettier
parent
840ab92bb4
commit
a2f20904b8
|
@ -0,0 +1 @@
|
|||
../../../../web_time_range_menu_custom
|
|
@ -0,0 +1,6 @@
|
|||
import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['setuptools-odoo'],
|
||||
odoo_addon=True,
|
||||
)
|
|
@ -33,7 +33,8 @@ odoo.define("web_time_range_menu_custom.ControlPanelModel", function(require) {
|
|||
if (groupOfTimeRanges && groupOfTimeRanges.activeFilterIds.length) {
|
||||
var filter = this.filters[groupOfTimeRanges.activeFilterIds[0][0]];
|
||||
if (filter.timeRangeId === "custom_period") {
|
||||
context.timeRangeMenuData.timeRange = Domain.prototype.constructCustomDomain(
|
||||
context.timeRangeMenuData.timeRange =
|
||||
Domain.prototype.constructCustomDomain(
|
||||
filter.fieldName,
|
||||
filter.timeRangeId,
|
||||
filter.fieldType,
|
||||
|
@ -48,12 +49,14 @@ odoo.define("web_time_range_menu_custom.ControlPanelModel", function(require) {
|
|||
context.timeRangeMenuData.timeRangeCustomType =
|
||||
filter.timeRangeCustom.type;
|
||||
if (evaluation) {
|
||||
context.timeRangeMenuData.timeRange = Domain.prototype.stringToArray(
|
||||
context.timeRangeMenuData.timeRange =
|
||||
Domain.prototype.stringToArray(
|
||||
context.timeRangeMenuData.timeRange
|
||||
);
|
||||
}
|
||||
if (filter.comparisonTimeRangeId !== "custom_comparison_period") {
|
||||
context.timeRangeMenuData.comparisonTimeRange = Domain.prototype.constructCustomDomain(
|
||||
context.timeRangeMenuData.comparisonTimeRange =
|
||||
Domain.prototype.constructCustomDomain(
|
||||
filter.fieldName,
|
||||
filter.timeRangeId,
|
||||
filter.fieldType,
|
||||
|
@ -62,14 +65,16 @@ odoo.define("web_time_range_menu_custom.ControlPanelModel", function(require) {
|
|||
filter.comparisonTimeRangeCustom
|
||||
);
|
||||
if (evaluation) {
|
||||
context.timeRangeMenuData.comparisonTimeRange = Domain.prototype.stringToArray(
|
||||
context.timeRangeMenuData.comparisonTimeRange =
|
||||
Domain.prototype.stringToArray(
|
||||
context.timeRangeMenuData.comparisonTimeRange
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (filter.comparisonTimeRangeId === "custom_comparison_period") {
|
||||
context.timeRangeMenuData.comparisonTimeRange = Domain.prototype.constructCustomDomain(
|
||||
context.timeRangeMenuData.comparisonTimeRange =
|
||||
Domain.prototype.constructCustomDomain(
|
||||
filter.fieldName,
|
||||
filter.timeRangeId,
|
||||
filter.fieldType,
|
||||
|
@ -86,7 +91,8 @@ odoo.define("web_time_range_menu_custom.ControlPanelModel", function(require) {
|
|||
filter.comparisonTimeRangeCustom.type;
|
||||
|
||||
if (evaluation) {
|
||||
context.timeRangeMenuData.comparisonTimeRange = Domain.prototype.stringToArray(
|
||||
context.timeRangeMenuData.comparisonTimeRange =
|
||||
Domain.prototype.stringToArray(
|
||||
context.timeRangeMenuData.comparisonTimeRange
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
/* Copyright 2021 Tecnativa - Alexandre D. Díaz
|
||||
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
|
||||
odoo.define("web_time_range_menu_custom.controlPanelViewParameters", function(require) {
|
||||
odoo.define(
|
||||
"web_time_range_menu_custom.controlPanelViewParameters",
|
||||
function (require) {
|
||||
"use strict";
|
||||
|
||||
const controlPanelViewParameters = require("web.controlPanelViewParameters");
|
||||
|
@ -8,13 +10,23 @@ odoo.define("web_time_range_menu_custom.controlPanelViewParameters", function(re
|
|||
|
||||
const _lt = core._lt;
|
||||
|
||||
controlPanelViewParameters.PERIOD_OPTIONS = controlPanelViewParameters.PERIOD_OPTIONS.concat(
|
||||
[{description: _lt("Custom Period"), optionId: "custom_period", groupId: 4}]
|
||||
);
|
||||
controlPanelViewParameters.PERIOD_OPTIONS =
|
||||
controlPanelViewParameters.PERIOD_OPTIONS.concat([
|
||||
{
|
||||
description: _lt("Custom Period"),
|
||||
optionId: "custom_period",
|
||||
groupId: 4,
|
||||
},
|
||||
]);
|
||||
controlPanelViewParameters.TIME_RANGE_OPTIONS =
|
||||
controlPanelViewParameters.PERIOD_OPTIONS;
|
||||
|
||||
controlPanelViewParameters.COMPARISON_TIME_RANGE_OPTIONS = controlPanelViewParameters.COMPARISON_TIME_RANGE_OPTIONS.concat(
|
||||
[{description: _lt("Custom Period"), optionId: "custom_comparison_period"}]
|
||||
controlPanelViewParameters.COMPARISON_TIME_RANGE_OPTIONS =
|
||||
controlPanelViewParameters.COMPARISON_TIME_RANGE_OPTIONS.concat([
|
||||
{
|
||||
description: _lt("Custom Period"),
|
||||
optionId: "custom_comparison_period",
|
||||
},
|
||||
]);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
@ -59,15 +59,13 @@ odoo.define("web_time_range_menu_custom.Domain", function(require) {
|
|||
break;
|
||||
case "custom_comparison_period":
|
||||
// This case is the addition for custom periods
|
||||
leftBoundaryParams[
|
||||
comparisonPeriodCustom.type
|
||||
] = leftBoundaryParams[comparisonPeriodCustom.type]
|
||||
leftBoundaryParams[comparisonPeriodCustom.type] =
|
||||
leftBoundaryParams[comparisonPeriodCustom.type]
|
||||
? leftBoundaryParams[comparisonPeriodCustom.type] -
|
||||
comparisonPeriodCustom.value
|
||||
: -comparisonPeriodCustom.value;
|
||||
rightBoundaryParams[
|
||||
comparisonPeriodCustom.type
|
||||
] = rightBoundaryParams[comparisonPeriodCustom.type]
|
||||
rightBoundaryParams[comparisonPeriodCustom.type] =
|
||||
rightBoundaryParams[comparisonPeriodCustom.type]
|
||||
? rightBoundaryParams[comparisonPeriodCustom.type] -
|
||||
comparisonPeriodCustom.value
|
||||
: -comparisonPeriodCustom.value;
|
||||
|
|
|
@ -28,10 +28,12 @@ odoo.define("web_time_range_menu_custom.TimeRangeMenu", function(require) {
|
|||
this.$selector_comparison_custom = this.$el.find(
|
||||
"#comparison_time_range_selector_custom"
|
||||
);
|
||||
this.$selector_comparison_custom_field_value = this.$selector_comparison_custom.find(
|
||||
this.$selector_comparison_custom_field_value =
|
||||
this.$selector_comparison_custom.find(
|
||||
"#date_field_selector_comparison_custom_value"
|
||||
);
|
||||
this.$selector_comparison_custom_field_type = this.$selector_comparison_custom.find(
|
||||
this.$selector_comparison_custom_field_type =
|
||||
this.$selector_comparison_custom.find(
|
||||
"#date_field_selector_comparison_custom_type"
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue