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 872a2b5..ff6e241 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 @@ -91,55 +91,57 @@ odoo.define('month_filter.searchUtils', function (require) { 4: { description: _lt("Q4"), coveredMonths: [9, 10, 11] }, }; const MONTH_OPTIONS = { - this_month: { - id: 'this_month', groupNumber: 1, format: 'MMMM', + first_month: { + id: 'first_month', groupNumber: 1, format: 'MMMM', addParam: {}, granularity: 'month', }, - last_month: { - id: 'last_month', groupNumber: 1, format: 'MMMM', - addParam: { months: -1 }, granularity: 'month', + second_month: { + id: 'second_month', groupNumber: 1, format: 'MMMM', + addParam: { months: +1 }, granularity: 'month', }, - antepenultimate_month: { - id: 'antepenultimate_month', groupNumber: 1, format: 'MMMM', - addParam: { months: -2 }, granularity: 'month', + third_month: { + id: 'third_month', groupNumber: 1, format: 'MMMM', + addParam: { months: +2 }, granularity: 'month', }, - antepenultimate_month_3: { - id: 'antepenultimate_month_3', groupNumber: 1, format: 'MMMM', - addParam: { months: -3 }, granularity: 'month', + fourth_month: { + id: 'fourth_month', groupNumber: 1, format: 'MMMM', + addParam: { months: +3 }, granularity: 'month', }, - antepenultimate_month_4: { - id: 'antepenultimate_month_4', groupNumber: 1, format: 'MMMM', - addParam: { months: -4 }, granularity: 'month', + fifth_month: { + id: 'fifth_month', groupNumber: 1, format: 'MMMM', + addParam: { months: +4 }, granularity: 'month', }, - antepenultimate_month_5: { - id: 'antepenultimate_month_5', groupNumber: 1, format: 'MMMM', - addParam: { months: -5 }, granularity: 'month', + sixth_month: { + id: 'sixth_month', groupNumber: 1, format: 'MMMM', + addParam: { months: +5 }, granularity: 'month', }, - antepenultimate_month_6: { - id: 'antepenultimate_month_6', groupNumber: 1, format: 'MMMM', - addParam: { months: -6 }, granularity: 'month', + seventh_month: { + id: 'seventh_month', groupNumber: 1, format: 'MMMM', + addParam: { months: +6 }, granularity: 'month', }, - antepenultimate_month_7: { - id: 'antepenultimate_month_7', groupNumber: 1, format: 'MMMM', - addParam: { months: -7 }, granularity: 'month', + eighth_month: { + id: 'eighth_month', groupNumber: 1, format: 'MMMM', + addParam: { months: +7 }, granularity: 'month', }, - antepenultimate_month_8: { - id: 'antepenultimate_month_8', groupNumber: 1, format: 'MMMM', - addParam: { months: -8 }, granularity: 'month', + ninth_month: { + id: 'ninth_month', groupNumber: 1, format: 'MMMM', + addParam: { months: +8 }, granularity: 'month', }, - antepenultimate_month_9: { - id: 'antepenultimate_month_9', groupNumber: 1, format: 'MMMM', - addParam: { months: -9 }, granularity: 'month', + tenth_month: { + id: 'tenth_month', groupNumber: 1, format: 'MMMM', + addParam: { months: +9 }, granularity: 'month', }, - antepenultimate_month_10: { - id: 'antepenultimate_month_10', groupNumber: 1, format: 'MMMM', - addParam: { months: -10 }, granularity: 'month', + eleventh_month: { + id: 'eleventh_month', groupNumber: 1, format: 'MMMM', + addParam: { months: +10 }, granularity: 'month', }, - antepenultimate_month_11: { - id: 'antepenultimate_month_11', groupNumber: 1, format: 'MMMM', - addParam: { months: -11 }, granularity: 'month', + twelfth_month: { + id: 'twelfth_month', groupNumber: 1, format: 'MMMM', + addParam: { months: +11 }, granularity: 'month', }, }; + + const QUARTER_OPTIONS = { fourth_quarter: { id: 'fourth_quarter', groupNumber: 1, description: QUARTERS[4].description, @@ -174,6 +176,7 @@ odoo.define('month_filter.searchUtils', function (require) { }; const PERIOD_OPTIONS = Object.assign({}, MONTH_OPTIONS, QUARTER_OPTIONS, YEAR_OPTIONS); + // GroupBy menu parameters const GROUPABLE_TYPES = [ 'boolean', @@ -444,7 +447,8 @@ odoo.define('month_filter.searchUtils', function (require) { for (const option of Object.values(PERIOD_OPTIONS)) { const { id, groupNumber, description, } = option; const res = { id, groupNumber, }; - const date = referenceMoment.clone().set(option.setParam).add(option.addParam); + const ref_date = referenceMoment.startOf('year'); + const date = ref_date.clone().set(option.setParam).add(option.addParam); if (description) { res.description = description.toString(); } else {