diff --git a/web_time_range_menu_custom/README.rst b/web_time_range_menu_custom/README.rst index 9a093d1c7..f3da3a2a0 100644 --- a/web_time_range_menu_custom/README.rst +++ b/web_time_range_menu_custom/README.rst @@ -17,13 +17,13 @@ Web Time Range Menu Custom :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github - :target: https://github.com/OCA/web/tree/15.0/web_time_range_menu_custom + :target: https://github.com/OCA/web/tree/16.0/web_time_range_menu_custom :alt: OCA/web .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_time_range_menu_custom + :target: https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_time_range_menu_custom :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=15.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -36,13 +36,33 @@ adding a new option called "Custom Period". .. contents:: :local: +Usage +===== + +To see this module working: + +#. Navigate to any menu that supports date-based filters. +#. Open **Custom period** tab. +#. Add new date filter with the provided options. + +.. image:: https://raw.githubusercontent.com/web_time_range_menu_custom/static/src/description/custom_period_option.png + :alt: Custom Period Option + +For the pivots, on the comparison tab you can see the same option to make the +comparison with the provided filter, taking th reference from the set filter. + +**Note:** For "days," it functions as a range; for example, "Last 7 days" returns the +period from 7 days ago up to today. However, for other options, it provides the +range for the selected period. For instance, "Last 1 month" returns the period from +the first day of the previous month to the last day of the previous month. + Bug Tracker =========== Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -75,6 +95,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -This module is part of the `OCA/web `_ project on GitHub. +This module is part of the `OCA/web `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_time_range_menu_custom/__manifest__.py b/web_time_range_menu_custom/__manifest__.py index 7ff9a88ba..7f5e6bc10 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": "15.0.1.0.1", + "version": "16.0.1.0.0", "author": "Tecnativa, Odoo Community Association (OCA)", "license": "AGPL-3", "website": "https://github.com/OCA/web", @@ -13,8 +13,6 @@ "web.assets_backend": [ "/web_time_range_menu_custom/static/src/js/*.esm.js", "/web_time_range_menu_custom/static/src/scss/*.scss", - ], - "web.assets_qweb": [ "/web_time_range_menu_custom/static/src/xml/*.xml", ], }, diff --git a/web_time_range_menu_custom/readme/USAGE.rst b/web_time_range_menu_custom/readme/USAGE.rst new file mode 100644 index 000000000..d975ed048 --- /dev/null +++ b/web_time_range_menu_custom/readme/USAGE.rst @@ -0,0 +1,16 @@ +To see this module working: + +#. Navigate to any menu that supports date-based filters. +#. Open **Custom period** tab. +#. Add new date filter with the provided options. + +.. image:: /web_time_range_menu_custom/static/src/description/custom_period_option.png + :alt: Custom Period Option + +For the pivots, on the comparison tab you can see the same option to make the +comparison with the provided filter, taking th reference from the set filter. + +**Note:** For "days," it functions as a range; for example, "Last 7 days" returns the +period from 7 days ago up to today. However, for other options, it provides the +range for the selected period. For instance, "Last 1 month" returns the period from +the first day of the previous month to the last day of the previous month. \ No newline at end of file diff --git a/web_time_range_menu_custom/static/description/custom_period_option.png b/web_time_range_menu_custom/static/description/custom_period_option.png new file mode 100644 index 000000000..c19c93488 Binary files /dev/null and b/web_time_range_menu_custom/static/description/custom_period_option.png differ diff --git a/web_time_range_menu_custom/static/description/index.html b/web_time_range_menu_custom/static/description/index.html index 86272d922..835902f6d 100644 --- a/web_time_range_menu_custom/static/description/index.html +++ b/web_time_range_menu_custom/static/description/index.html @@ -1,4 +1,3 @@ - @@ -9,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +275,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code { margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +301,7 @@ span.option { span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -369,39 +369,56 @@ ul.auto-toc { !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:a7d5190a01dc1568ba62760ae6498f4385a83f98164c3012312979ca764ff49f !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runboat

+

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runboat

Extend period and comparison period options for the date and datetime fields filted menu adding a new option called “Custom Period”.

Table of contents

+
+

Usage

+

To see this module working:

+
    +
  1. Navigate to any menu that supports date-based filters.
  2. +
  3. Open Custom period tab.
  4. +
  5. Add new date filter with the provided options.
  6. +
+Custom Period Option +

For the pivots, on the comparison tab you can see the same option to make the +comparison with the provided filter, taking th reference from the set filter.

+

Note: For “days,” it functions as a range; for example, “Last 7 days” returns the +period from 7 days ago up to today. However, for other options, it provides the +range for the selected period. For instance, “Last 1 month” returns the period from +the first day of the previous month to the last day of the previous month.

+
-

Bug Tracker

+

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

-

Credits

+

Credits

-

Authors

+

Authors

  • Tecnativa
-

Contributors

+

Contributors

  • Tecnativa:
    • Alexandre D. Díaz
    • @@ -411,13 +428,15 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
-

Maintainers

+

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

-

This module is part of the OCA/web project on GitHub.

+

This module is part of the OCA/web project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/web_time_range_menu_custom/static/src/js/comparison_menu.esm.js b/web_time_range_menu_custom/static/src/js/comparison_menu.esm.js new file mode 100644 index 000000000..d6dcb0b98 --- /dev/null +++ b/web_time_range_menu_custom/static/src/js/comparison_menu.esm.js @@ -0,0 +1,13 @@ +/** @odoo-module **/ +/* Copyright 2024 Tecnativa - Carlos Roca + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) */ +import {ComparisonMenu} from "@web/search/comparison_menu/comparison_menu"; +import {DropdownItemCustomPeriod} from "./date_selector.esm"; +import {patch} from "@web/core/utils/patch"; + +patch(ComparisonMenu, "web_time_range_menu_custom.FilterMenu", { + components: { + ...ComparisonMenu.components, + DropdownItemCustomPeriod, + }, +}); diff --git a/web_time_range_menu_custom/static/src/js/date_selector.esm.js b/web_time_range_menu_custom/static/src/js/date_selector.esm.js index 71dcb3003..2fb1f62a4 100644 --- a/web_time_range_menu_custom/static/src/js/date_selector.esm.js +++ b/web_time_range_menu_custom/static/src/js/date_selector.esm.js @@ -3,8 +3,7 @@ * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) */ import {useBus} from "@web/core/utils/hooks"; -const {Component, QWeb} = owl; -const {useState} = owl.hooks; +const {Component, useState} = owl; import * as dates from "@web/search/utils/dates"; const {DateTime} = luxon; // eslint-disable-line no-undef var ID_CUSTOM_DATE = 0; @@ -120,4 +119,3 @@ DropdownItemCustomPeriod.props = { field: {type: Object, optional: true}, comparisonItems: {type: Object, optional: true}, }; -QWeb.registerComponent("DropdownItemCustomPeriod", DropdownItemCustomPeriod); diff --git a/web_time_range_menu_custom/static/src/js/dates.esm.js b/web_time_range_menu_custom/static/src/js/dates.esm.js index fbc65b68e..f5be25fd6 100644 --- a/web_time_range_menu_custom/static/src/js/dates.esm.js +++ b/web_time_range_menu_custom/static/src/js/dates.esm.js @@ -84,9 +84,13 @@ patch(dates, "patch dates", { }; if (otherOptions.length) { for (const option of otherOptions) { + const year_param = + option.granularity === "week" + ? {weekYear: yearOption.setParam.year} + : yearOption.setParam; const setParam = Object.assign( {}, - yearOption.setParam, + year_param, option ? option.setParam : {} ); const {granularity, custom_period} = option; diff --git a/web_time_range_menu_custom/static/src/js/filter_menu.esm.js b/web_time_range_menu_custom/static/src/js/filter_menu.esm.js new file mode 100644 index 000000000..c0999ca09 --- /dev/null +++ b/web_time_range_menu_custom/static/src/js/filter_menu.esm.js @@ -0,0 +1,13 @@ +/** @odoo-module **/ +/* Copyright 2024 Tecnativa - Carlos Roca + * License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) */ +import {FilterMenu} from "@web/search/filter_menu/filter_menu"; +import {DropdownItemCustomPeriod} from "./date_selector.esm"; +import {patch} from "@web/core/utils/patch"; + +patch(FilterMenu, "web_time_range_menu_custom.FilterMenu", { + components: { + ...FilterMenu.components, + DropdownItemCustomPeriod, + }, +});