[MIG] web_time_range_menu_custom: Migration to 16.0

pull/2993/head
Carlos Roca 2024-11-19 08:35:06 +01:00
parent c2ad3b0593
commit 7a9d542c0a
9 changed files with 111 additions and 30 deletions

View File

@ -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 <https://github.com/OCA/web/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 <https://github.com/OCA/web/issues/new?body=module:%20web_time_range_menu_custom%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_time_range_menu_custom%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
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 <https://github.com/OCA/web/tree/15.0/web_time_range_menu_custom>`_ project on GitHub.
This module is part of the `OCA/web <https://github.com/OCA/web/tree/16.0/web_time_range_menu_custom>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

View File

@ -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",
],
},

View File

@ -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.

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 KiB

View File

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
@ -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
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/15.0/web_time_range_menu_custom"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_time_range_menu_custom"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/16.0/web_time_range_menu_custom"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_time_range_menu_custom"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Extend period and comparison period options for the date and datetime fields filted menu
adding a new option called “Custom Period”.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-1">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-2">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-3">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-4">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-5">Maintainers</a></li>
<li><a class="reference internal" href="#usage" id="toc-entry-1">Usage</a></li>
<li><a class="reference internal" href="#bug-tracker" id="toc-entry-2">Bug Tracker</a></li>
<li><a class="reference internal" href="#credits" id="toc-entry-3">Credits</a><ul>
<li><a class="reference internal" href="#authors" id="toc-entry-4">Authors</a></li>
<li><a class="reference internal" href="#contributors" id="toc-entry-5">Contributors</a></li>
<li><a class="reference internal" href="#maintainers" id="toc-entry-6">Maintainers</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="usage">
<h1><a class="toc-backref" href="#toc-entry-1">Usage</a></h1>
<p>To see this module working:</p>
<ol class="arabic simple">
<li>Navigate to any menu that supports date-based filters.</li>
<li>Open <strong>Custom period</strong> tab.</li>
<li>Add new date filter with the provided options.</li>
</ol>
<img alt="Custom Period Option" src="https://raw.githubusercontent.com/web_time_range_menu_custom/static/src/description/custom_period_option.png" />
<p>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.</p>
<p><strong>Note:</strong> 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.</p>
</div>
<div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#toc-entry-1">Bug Tracker</a></h1>
<h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
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
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_time_range_menu_custom%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_time_range_menu_custom%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
<h1><a class="toc-backref" href="#toc-entry-2">Credits</a></h1>
<h1><a class="toc-backref" href="#toc-entry-3">Credits</a></h1>
<div class="section" id="authors">
<h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-4">Authors</a></h2>
<ul class="simple">
<li>Tecnativa</li>
</ul>
</div>
<div class="section" id="contributors">
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<ul class="simple">
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Alexandre D. Díaz</li>
@ -411,13 +428,15 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
</ul>
</div>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-5">Maintainers</a></h2>
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>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.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/15.0/web_time_range_menu_custom">OCA/web</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/16.0/web_time_range_menu_custom">OCA/web</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>

View File

@ -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,
},
});

View File

@ -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);

View File

@ -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;

View File

@ -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,
},
});