Skip to content

Commit

Permalink
[MIG] date_range: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sonhd91 committed Jan 2, 2024
1 parent 80bfe27 commit 3cc6fe2
Show file tree
Hide file tree
Showing 28 changed files with 1,039 additions and 620 deletions.
22 changes: 12 additions & 10 deletions date_range/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Date Range
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:7ac329a54e4115f5c8dbd5632b367441f95e916f546be892a7424d5c0e75bd90
!! source digest: sha256:e2919483079ba46556509d8e01e275d6cc04f8ded2dd0ec9eda322bd994b2008
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png
Expand Down Expand Up @@ -72,7 +72,7 @@ model:

_date_range_search_field = "invoice_date"

.. |image1| image:: https://raw.githubusercontent.com/OCA/server-tools/12.0/date_range/static/description/date_range_many2one_search_field.png
.. |image1| image:: https://raw.githubusercontent.com/OCA/server-tools/17.0/date_range/static/description/date_range_many2one_search_field.png

Usage
=====
Expand Down Expand Up @@ -124,14 +124,14 @@ To configure this module, you need to:

|image8|

.. |image1| image:: https://raw.githubusercontent.com/OCA/server-tools/14.0/date_range/static/description/date_range_type_create.png
.. |image2| image:: https://raw.githubusercontent.com/OCA/server-tools/14.0/date_range/static/description/date_range_create.png
.. |image3| image:: https://raw.githubusercontent.com/OCA/server-tools/14.0/date_range/static/description/date_range_wizard.png
.. |image4| image:: https://raw.githubusercontent.com/OCA/server-tools/14.0/date_range/static/description/date_range_wizard_result.png
.. |image5| image:: https://raw.githubusercontent.com/OCA/server-tools/14.0/date_range/static/description/date_range_type_as_filter.png
.. |image6| image:: https://raw.githubusercontent.com/OCA/server-tools/14.0/date_range/static/description/date_range_as_filter.png
.. |image7| image:: https://raw.githubusercontent.com/OCA/server-tools/14.0/date_range/static/description/date_range_as_filter_result.png
.. |image8| image:: https://raw.githubusercontent.com/OCA/server-tools/14.0/date_range/static/description/date_range_type_autogeneration.png
.. |image1| image:: https://raw.githubusercontent.com/OCA/server-tools/17.0/date_range/static/description/date_range_type_create.png
.. |image2| image:: https://raw.githubusercontent.com/OCA/server-tools/17.0/date_range/static/description/date_range_create.png
.. |image3| image:: https://raw.githubusercontent.com/OCA/server-tools/17.0/date_range/static/description/date_range_wizard.png
.. |image4| image:: https://raw.githubusercontent.com/OCA/server-tools/17.0/date_range/static/description/date_range_wizard_result.png
.. |image5| image:: https://raw.githubusercontent.com/OCA/server-tools/17.0/date_range/static/description/date_range_type_as_filter.png
.. |image6| image:: https://raw.githubusercontent.com/OCA/server-tools/17.0/date_range/static/description/date_range_as_filter.png
.. |image7| image:: https://raw.githubusercontent.com/OCA/server-tools/17.0/date_range/static/description/date_range_as_filter_result.png
.. |image8| image:: https://raw.githubusercontent.com/OCA/server-tools/17.0/date_range/static/description/date_range_type_autogeneration.png

Bug Tracker
===========
Expand Down Expand Up @@ -159,6 +159,8 @@ Contributors
- Miquel Raïch <miquel.raich@forgeflow.com>
- Andrea Stirpe <a.stirpe@onestein.nl>
- Stefan Rijnhart <stefan@opener.amsterdam>
- David Ramia <<@ramiadavid>>
- Son Ho <sonhd@trobz.com>

Maintainers
-----------
Expand Down
9 changes: 3 additions & 6 deletions date_range/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
{
"name": "Date Range",
"summary": "Manage all kind of date range",
"version": "16.0.1.0.9",
"version": "17.0.1.0.0",
"category": "Uncategorized",
"website": "https://github.com/OCA/server-ux",
"author": "ACSONE SA/NV, Odoo Community Association (OCA)",
"license": "LGPL-3",
"installable": True,
"depends": [
"web",
],
"depends": ["web"],
"data": [
"data/ir_cron_data.xml",
"security/ir.model.access.csv",
Expand All @@ -21,8 +19,7 @@
],
"assets": {
"web.assets_backend": [
"date_range/static/src/js/date_range.esm.js",
"date_range/static/src/xml/date_range.xml",
"date_range/static/src/js/*",
],
},
"development_status": "Mature",
Expand Down
12 changes: 11 additions & 1 deletion date_range/models/date_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def _default_company(self):
active = fields.Boolean(
help="The active field allows you to hide the date range without "
"removing it.",
default=True,
compute="_compute_active",
readonly=False,
store=True,
)

_sql_constraints = [
Expand All @@ -45,6 +47,14 @@ def _default_company(self):
)
]

@api.depends("type_id.active")
def _compute_active(self):
for date in self:
if date.type_id.active:
date.active = True
else:
date.active = False

@api.constrains("type_id", "date_start", "date_end", "company_id")
def _validate_range(self):
for this in self:
Expand Down
5 changes: 3 additions & 2 deletions date_range/models/date_range_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def _check_company_id(self):
continue
if bool(
rec.date_range_ids.filtered(
lambda r: r.company_id and r.company_id != rec.company_id
lambda r, drt=rec: r.company_id
and r.company_id != drt.company_id
)
):
raise ValidationError(
Expand Down Expand Up @@ -144,5 +145,5 @@ def autogenerate_ranges(self):
except Exception as e:
logger.warning(
"Error autogenerating ranges for date range type "
"%s: %s" % (dr_type.name, e)
f"{dr_type.name}: {e}"
)
2 changes: 1 addition & 1 deletion date_range/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AccountMove(models.Model):

This will make a Period field show up in the search view:

> ![](https://raw.githubusercontent.com/OCA/server-tools/12.0/date_range/static/description/date_range_many2one_search_field.png)
> ![](https://raw.githubusercontent.com/OCA/server-tools/17.0/date_range/static/description/date_range_many2one_search_field.png)
By default, the mixin works on the date field. If you want the mixin to
work on a field with a different name, you can set a property on your
Expand Down
2 changes: 2 additions & 0 deletions date_range/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
- Miquel Raïch \<<miquel.raich@forgeflow.com>\>
- Andrea Stirpe \<<a.stirpe@onestein.nl>\>
- Stefan Rijnhart \<<stefan@opener.amsterdam>\>
- David Ramia \<<@ramiadavid>\>
- Son Ho \<<sonhd@trobz.com>\>
16 changes: 8 additions & 8 deletions date_range/readme/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,43 @@ To configure this module, you need to:
- Go to Settings \> Technical \> Date ranges \> Date Range Types where
you can create types of date ranges.

![](https://raw.githubusercontent.com/OCA/server-tools/14.0/date_range/static/description/date_range_type_create.png)
![](https://raw.githubusercontent.com/OCA/server-tools/17.0/date_range/static/description/date_range_type_create.png)

- Go to Settings \> Technical \> Date ranges \> Date Ranges where you
can create date ranges.

![](https://raw.githubusercontent.com/OCA/server-tools/14.0/date_range/static/description/date_range_create.png)
![](https://raw.githubusercontent.com/OCA/server-tools/17.0/date_range/static/description/date_range_create.png)

It's also possible to launch a wizard from the 'Generate Date Ranges'
menu.

![](https://raw.githubusercontent.com/OCA/server-tools/14.0/date_range/static/description/date_range_wizard.png)
![](https://raw.githubusercontent.com/OCA/server-tools/17.0/date_range/static/description/date_range_wizard.png)

The wizard is useful to generate recurring periods. Set an end date or
enter the number of ranges to create.

![](https://raw.githubusercontent.com/OCA/server-tools/14.0/date_range/static/description/date_range_wizard_result.png)
![](https://raw.githubusercontent.com/OCA/server-tools/17.0/date_range/static/description/date_range_wizard_result.png)

- Your date ranges are now available in the search filter for any date
or datetime fields

Date range types are proposed as a filter operator

![](https://raw.githubusercontent.com/OCA/server-tools/14.0/date_range/static/description/date_range_type_as_filter.png)
![](https://raw.githubusercontent.com/OCA/server-tools/17.0/date_range/static/description/date_range_type_as_filter.png)

Once a type is selected, date ranges of this type are porposed as a
filter value

![](https://raw.githubusercontent.com/OCA/server-tools/14.0/date_range/static/description/date_range_as_filter.png)
![](https://raw.githubusercontent.com/OCA/server-tools/17.0/date_range/static/description/date_range_as_filter.png)

And the dates specified into the date range are used to filter your
result.

![](https://raw.githubusercontent.com/OCA/server-tools/14.0/date_range/static/description/date_range_as_filter_result.png)
![](https://raw.githubusercontent.com/OCA/server-tools/17.0/date_range/static/description/date_range_as_filter_result.png)

- You can configure date range types with default values for the
generation wizard on the Generation tab. In the same tab you can also
configure date range types for auto-generation. New ranges for types
configured for this are generated by a scheduled task that runs daily.

![](https://raw.githubusercontent.com/OCA/server-tools/14.0/date_range/static/description/date_range_type_autogeneration.png)
![](https://raw.githubusercontent.com/OCA/server-tools/17.0/date_range/static/description/date_range_type_autogeneration.png)
Binary file modified date_range/static/description/date_range_as_filter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified date_range/static/description/date_range_as_filter_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified date_range/static/description/date_range_create.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified date_range/static/description/date_range_type_as_filter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified date_range/static/description/date_range_type_autogeneration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified date_range/static/description/date_range_type_create.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified date_range/static/description/date_range_wizard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified date_range/static/description/date_range_wizard_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 3cc6fe2

Please sign in to comment.