diff options
| author | Lucas Lefèvre <lul@odoo.com> | 2020-05-14 07:53:32 +0000 |
|---|---|---|
| committer | Lucas Lefèvre <lul@odoo.com> | 2020-05-15 10:47:38 +0000 |
| commit | 5d50509be84e77529f04a33199ad2ec1f547645a (patch) | |
| tree | 2e9d2f9f39245d398d4b579d81108fdcfa3700d7 /addons/resource | |
| parent | a814b671ed2d7359c45d4b4ca0ef2c14da62b43c (diff) | |
[FIX] resource: Fail fast if no calendar
The methods `get_work_hours_count` and `_attendance_intervals`
raise a traceback if `self` does not contain a single calendar record.
This commit adds an explicit check for this requirement.
Related PR odoo/enterprise#10593
closes odoo/odoo#51326
X-original-commit: e5d93be382b03c7a9c925b4a2e6be6875843195d
Related: odoo/enterprise#10619
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons/resource')
| -rw-r--r-- | addons/resource/models/resource.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/addons/resource/models/resource.py b/addons/resource/models/resource.py index 4c2f2409dc7..7c497a61856 100644 --- a/addons/resource/models/resource.py +++ b/addons/resource/models/resource.py @@ -343,6 +343,7 @@ class ResourceCalendar(models.Model): The returned intervals are expressed in specified tz or in the resource's timezone. """ assert start_dt.tzinfo and end_dt.tzinfo + self.ensure_one() combine = datetime.combine resource_ids = [resource.id, False] if resource else [False] @@ -505,6 +506,7 @@ class ResourceCalendar(models.Model): Counts the number of work hours between two datetimes. """ + self.ensure_one() # Set timezone in UTC if no timezone is explicitly given if not start_dt.tzinfo: start_dt = start_dt.replace(tzinfo=utc) |
