diff --git a/month_filter/__manifest__.py b/month_filter/__manifest__.py index 888d624..d938abd 100644 --- a/month_filter/__manifest__.py +++ b/month_filter/__manifest__.py @@ -5,9 +5,9 @@ 'author': 'SunArc Technologies', 'website': 'www.sunarctechnologies.com', 'license': 'LGPL-3', - 'depends': ['base','web'], + 'depends': ['base','web' ,'hr_timesheet'], 'data': [ - 'views/templates.xml' + 'views/templates.xml', ], 'installable': True, 'auto_install': False, diff --git a/month_filter/static/src/js/control_panel/control_panel_custom_extension.js b/month_filter/static/src/js/control_panel/control_panel_custom_extension.js new file mode 100644 index 0000000..af861e3 --- /dev/null +++ b/month_filter/static/src/js/control_panel/control_panel_custom_extension.js @@ -0,0 +1,39 @@ +odoo.define('month_filter.ModeExtension', function (require) { + "use strict"; + const components = { + ControlPanelModelExtension: require("web/static/src/js/control_panel/control_panel_model_extension.js"), + }; + const { patch } = require("web.utils"); + const Domain = require('web.Domain'); + const pyUtils = require('web.py_utils'); + + const { DEFAULT_INTERVAL, DEFAULT_PERIOD, + getComparisonOptions, getIntervalOptions, getPeriodOptions, + constructDateDomain, rankInterval, yearSelected } = require('month_filter.searchUtils'); + + patch( + components.ControlPanelModelExtension, + "month_filter/static/src/js/control_panel/control_panel_custom_extension.js", + { + toggleFilterWithOptions(filterId, optionId) { + this.referenceMoment = moment(); + this.optionGenerators = getPeriodOptions(this.referenceMoment); + return this._super(filterId, optionId); + }, + _enrichFilterCopy(filter, filterQueryElements) { + this.referenceMoment = moment(); + this.optionGenerators = getPeriodOptions(this.referenceMoment); + return this._super(filter, filterQueryElements); + }, + _getDateFilterDomain(filter, filterQueryElements, key = 'domain') { + const { fieldName, fieldType } = filter; + const selectedOptionIds = filterQueryElements.map(queryElem => queryElem.optionId); + + const dateFilterRange = constructDateDomain( + this.referenceMoment, fieldName, fieldType, selectedOptionIds, + ); + return dateFilterRange[key]; + }, + } + ); + }); \ No newline at end of file diff --git a/month_filter/static/src/js/control_panel/custom_search_utils.js b/month_filter/static/src/js/control_panel/custom_search_utils.js index ff81906..872a2b5 100644 --- a/month_filter/static/src/js/control_panel/custom_search_utils.js +++ b/month_filter/static/src/js/control_panel/custom_search_utils.js @@ -1,4 +1,4 @@ -odoo.define('web.searchUtils', function (require) { +odoo.define('month_filter.searchUtils', function (require) { "use strict"; const { _lt, _t } = require('web.core'); diff --git a/month_filter/views/templates.xml b/month_filter/views/templates.xml index 5746cce..30b5323 100644 --- a/month_filter/views/templates.xml +++ b/month_filter/views/templates.xml @@ -3,6 +3,7 @@