Skip to content

Commit 11df449

Browse files
committed
[MIG] date_range: Migration to 19.0
1 parent a8be2e1 commit 11df449

File tree

7 files changed

+57
-50
lines changed

7 files changed

+57
-50
lines changed

date_range/README.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.. image:: https://odoo-community.org/readme-banner-image
2+
:target: https://odoo-community.org/get-involved?utm_source=readme
3+
:alt: Odoo Community Association
4+
15
==========
26
Date Range
37
==========
@@ -13,17 +17,17 @@ Date Range
1317
.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png
1418
:target: https://odoo-community.org/page/development-status
1519
:alt: Mature
16-
.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png
20+
.. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png
1721
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
1822
:alt: License: LGPL-3
1923
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--ux-lightgray.png?logo=github
20-
:target: https://github.com/OCA/server-ux/tree/18.0/date_range
24+
:target: https://github.com/OCA/server-ux/tree/19.0/date_range
2125
:alt: OCA/server-ux
2226
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
23-
:target: https://translation.odoo-community.org/projects/server-ux-18-0/server-ux-18-0-date_range
27+
:target: https://translation.odoo-community.org/projects/server-ux-19-0/server-ux-19-0-date_range
2428
:alt: Translate me on Weblate
2529
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
26-
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-ux&target_branch=18.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-ux&target_branch=19.0
2731
:alt: Try me on Runboat
2832

2933
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -139,7 +143,7 @@ Bug Tracker
139143
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-ux/issues>`_.
140144
In case of trouble, please check there if your issue has already been reported.
141145
If you spotted it first, help us to smash it by providing a detailed and welcomed
142-
`feedback <https://github.com/OCA/server-ux/issues/new?body=module:%20date_range%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
146+
`feedback <https://github.com/OCA/server-ux/issues/new?body=module:%20date_range%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
143147

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

@@ -184,6 +188,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
184188

185189
|maintainer-lmignon|
186190

187-
This module is part of the `OCA/server-ux <https://github.com/OCA/server-ux/tree/18.0/date_range>`_ project on GitHub.
191+
This module is part of the `OCA/server-ux <https://github.com/OCA/server-ux/tree/19.0/date_range>`_ project on GitHub.
188192

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

date_range/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"name": "Date Range",
55
"summary": "Manage all kind of date range",
6-
"version": "18.0.1.0.0",
6+
"version": "19.0.1.0.0",
77
"category": "Uncategorized",
88
"website": "https://github.com/OCA/server-ux",
99
"author": "ACSONE SA/NV, Odoo Community Association (OCA)",

date_range/models/date_range.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _default_company(self):
3030
comodel_name="res.company",
3131
string="Company",
3232
index=True,
33-
default=_default_company,
33+
default=lambda self: self._default_company(),
3434
)
3535
active = fields.Boolean(
3636
help="The active field allows you to hide the date range without removing it.",
@@ -39,13 +39,10 @@ def _default_company(self):
3939
store=True,
4040
)
4141

42-
_sql_constraints = [
43-
(
44-
"date_range_uniq",
45-
"unique (name,type_id, company_id)",
46-
"A date range must be unique per company !",
47-
)
48-
]
42+
_date_range_uniq = models.Constraint(
43+
"unique (name,type_id, company_id)",
44+
"A date range must be unique per company !",
45+
)
4946

5047
@api.depends("type_id.active")
5148
def _compute_active(self):
@@ -61,13 +58,11 @@ def _validate_range(self):
6158
if this.date_start > this.date_end:
6259
raise ValidationError(
6360
self.env._(
64-
"%(name)s is not a valid range (%(date_start)s > %(date_end)s)"
61+
"%(name)s is not a valid range (%(date_start)s > %(date_end)s)",
62+
name=this.name,
63+
date_start=this.date_start,
64+
date_end=this.date_end,
6565
)
66-
% {
67-
"name": this.name,
68-
"date_start": this.date_start,
69-
"date_end": this.date_end,
70-
}
7166
)
7267
if this.type_id.allow_overlap:
7368
continue
@@ -100,8 +95,11 @@ def _validate_range(self):
10095
if res:
10196
dt = self.browse(res[0][0])
10297
raise ValidationError(
103-
self.env._("%(thisname)s overlaps %(dtname)s")
104-
% {"thisname": this.name, "dtname": dt.name}
98+
self.env._(
99+
"%(thisname)s overlaps %(dtname)s",
100+
thisname=this.name,
101+
dtname=dt.name,
102+
)
105103
)
106104

107105
def get_domain(self, field_name):

date_range/models/date_range_type.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ def _default_company(self):
2828
default=True,
2929
)
3030
company_id = fields.Many2one(
31-
comodel_name="res.company", string="Company", index=1, default=_default_company
31+
comodel_name="res.company",
32+
string="Company",
33+
index=1,
34+
default=lambda self: self._default_company(),
3235
)
3336
date_range_ids = fields.One2many("date.range", "type_id", string="Ranges")
3437
date_ranges_exist = fields.Boolean(compute="_compute_date_ranges_exist")
@@ -68,13 +71,10 @@ def _default_company(self):
6871
]
6972
)
7073

71-
_sql_constraints = [
72-
(
73-
"date_range_type_uniq",
74-
"unique (name,company_id)",
75-
"A date range type must be unique per company !",
76-
)
77-
]
74+
_date_range_type_uniq = models.Constraint(
75+
"unique (name,company_id)",
76+
"A date range type must be unique per company !",
77+
)
7878

7979
@api.constrains("company_id")
8080
def _check_company_id(self):
@@ -91,9 +91,9 @@ def _check_company_id(self):
9191
raise ValidationError(
9292
self.env._(
9393
"You cannot change the company, as this "
94-
"Date Range Type is assigned to Date Range '%s'."
94+
"Date Range Type is assigned to Date Range '%s'.",
95+
rec.date_range_ids.display_name,
9596
)
96-
% (rec.date_range_ids.display_name)
9797
)
9898

9999
@api.depends("name_expr", "name_prefix")

date_range/static/description/index.html

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
55
<meta name="generator" content="Docutils: https://docutils.sourceforge.io/" />
6-
<title>Date Range</title>
6+
<title>README.rst</title>
77
<style type="text/css">
88

99
/*
@@ -360,16 +360,21 @@
360360
</style>
361361
</head>
362362
<body>
363-
<div class="document" id="date-range">
364-
<h1 class="title">Date Range</h1>
363+
<div class="document">
365364

365+
366+
<a class="reference external image-reference" href="https://odoo-community.org/get-involved?utm_source=readme">
367+
<img alt="Odoo Community Association" src="https://odoo-community.org/readme-banner-image" />
368+
</a>
369+
<div class="section" id="date-range">
370+
<h1>Date Range</h1>
366371
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
367372
!! This file is generated by oca-gen-addon-readme !!
368373
!! changes will be overwritten. !!
369374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
370375
!! source digest: sha256:26156f1d5b0f8d700a7fa2a8a81ce509bfa25d8eb261aefc72986f03e59ee04a
371376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
372-
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/licence-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-ux/tree/18.0/date_range"><img alt="OCA/server-ux" src="https://img.shields.io/badge/github-OCA%2Fserver--ux-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-ux-18-0/server-ux-18-0-date_range"><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/server-ux&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
377+
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Mature" src="https://img.shields.io/badge/maturity-Mature-brightgreen.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/lgpl-3.0-standalone.html"><img alt="License: LGPL-3" src="https://img.shields.io/badge/license-LGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-ux/tree/19.0/date_range"><img alt="OCA/server-ux" src="https://img.shields.io/badge/github-OCA%2Fserver--ux-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-ux-19-0/server-ux-19-0-date_range"><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/server-ux&amp;target_branch=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
373378
<p>This module lets you define global date ranges that can be used to
374379
filter your values in tree views.</p>
375380
<p>It also provides a mixin model for developers that extends the model’s
@@ -390,12 +395,12 @@ <h1 class="title">Date Range</h1>
390395
</ul>
391396
</div>
392397
<div class="section" id="installation">
393-
<h1><a class="toc-backref" href="#toc-entry-1">Installation</a></h1>
398+
<h2><a class="toc-backref" href="#toc-entry-1">Installation</a></h2>
394399
<p>The addon use the daterange method from postgres. This method is
395400
supported as of postgresql 9.2</p>
396401
</div>
397402
<div class="section" id="configuration">
398-
<h1><a class="toc-backref" href="#toc-entry-2">Configuration</a></h1>
403+
<h2><a class="toc-backref" href="#toc-entry-2">Configuration</a></h2>
399404
<p>For regular usage, see Usage below. This section is to clarify optional
400405
functionality to developers.</p>
401406
<p>To configure a model to use the Many2one style search field, make the
@@ -416,7 +421,7 @@ <h1><a class="toc-backref" href="#toc-entry-2">Configuration</a></h1>
416421
</pre>
417422
</div>
418423
<div class="section" id="usage">
419-
<h1><a class="toc-backref" href="#toc-entry-3">Usage</a></h1>
424+
<h2><a class="toc-backref" href="#toc-entry-3">Usage</a></h2>
420425
<p>To configure this module, you need to:</p>
421426
<ul>
422427
<li><p class="first">Go to Settings &gt; Technical &gt; Date ranges &gt; Date Range Types where you
@@ -454,23 +459,23 @@ <h1><a class="toc-backref" href="#toc-entry-3">Usage</a></h1>
454459
</ul>
455460
</div>
456461
<div class="section" id="bug-tracker">
457-
<h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
462+
<h2><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h2>
458463
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-ux/issues">GitHub Issues</a>.
459464
In case of trouble, please check there if your issue has already been reported.
460465
If you spotted it first, help us to smash it by providing a detailed and welcomed
461-
<a class="reference external" href="https://github.com/OCA/server-ux/issues/new?body=module:%20date_range%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
466+
<a class="reference external" href="https://github.com/OCA/server-ux/issues/new?body=module:%20date_range%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
462467
<p>Do not contact contributors directly about support or help with technical issues.</p>
463468
</div>
464469
<div class="section" id="credits">
465-
<h1><a class="toc-backref" href="#toc-entry-5">Credits</a></h1>
470+
<h2><a class="toc-backref" href="#toc-entry-5">Credits</a></h2>
466471
<div class="section" id="authors">
467-
<h2><a class="toc-backref" href="#toc-entry-6">Authors</a></h2>
472+
<h3><a class="toc-backref" href="#toc-entry-6">Authors</a></h3>
468473
<ul class="simple">
469474
<li>ACSONE SA/NV</li>
470475
</ul>
471476
</div>
472477
<div class="section" id="contributors">
473-
<h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
478+
<h3><a class="toc-backref" href="#toc-entry-7">Contributors</a></h3>
474479
<ul class="simple">
475480
<li>Laurent Mignon &lt;<a class="reference external" href="mailto:laurent.mignon&#64;acsone.eu">laurent.mignon&#64;acsone.eu</a>&gt;</li>
476481
<li>Alexis de Lattre &lt;<a class="reference external" href="mailto:alexis.delattre&#64;akretion.com">alexis.delattre&#64;akretion.com</a>&gt;</li>
@@ -483,7 +488,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
483488
</ul>
484489
</div>
485490
<div class="section" id="maintainers">
486-
<h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
491+
<h3><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h3>
487492
<p>This module is maintained by the OCA.</p>
488493
<a class="reference external image-reference" href="https://odoo-community.org">
489494
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
@@ -493,10 +498,11 @@ <h2><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h2>
493498
promote its widespread use.</p>
494499
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
495500
<p><a class="reference external image-reference" href="https://github.com/lmignon"><img alt="lmignon" src="https://github.com/lmignon.png?size=40px" /></a></p>
496-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-ux/tree/18.0/date_range">OCA/server-ux</a> project on GitHub.</p>
501+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-ux/tree/19.0/date_range">OCA/server-ux</a> project on GitHub.</p>
497502
<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>
498503
</div>
499504
</div>
500505
</div>
506+
</div>
501507
</body>
502508
</html>

date_range/static/src/js/condition_tree.esm.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* global document */
21
import {
32
condition,
43
connector,

date_range/wizard/date_range_generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def _generate_names(self, vals, name_expr, name_prefix):
171171
# always remove 1 day for the date_end since range limits are
172172
# inclusive
173173
date_end = vals[idx + 1].date() - relativedelta(days=1)
174-
index = "%0*d" % (count_digits, idx + 1)
174+
index = f"{idx + 1:0{count_digits}d}"
175175
if name_expr:
176176
try:
177177
names.append(
@@ -186,7 +186,7 @@ def _generate_names(self, vals, name_expr, name_prefix):
186186
)
187187
except (SyntaxError, ValueError) as e:
188188
raise ValidationError(
189-
self.env._("Invalid name expression: %s") % e
189+
self.env._("Invalid name expression: %s", e)
190190
) from e
191191
elif name_prefix:
192192
names.append(name_prefix + index)

0 commit comments

Comments
 (0)