summaryrefslogtreecommitdiff
path: root/odoo/models.py
diff options
context:
space:
mode:
authorNicolas Lempereur <nle@odoo.com>2020-07-03 13:40:53 +0000
committerNicolas Lempereur <nle@odoo.com>2020-07-10 15:39:25 +0000
commit930db42b3acdc88d11bf54322b6a0362d7715ebf (patch)
tree8ce6601d3c50ff9ce18d0c327eb7e61f9ec53c58 /odoo/models.py
parentbffb3b7fced799a1d8c052cf766c50263de5d2bc (diff)
[FIX] models.py: group by date with DST change
When we group by date with DST change within a range, we could get a reocrd inside two date range grouping, or inside no grouping. This is because we computed range just with [+ 1 month], so we possibly had these ranges (in UTC): - October 2019 : [('datetime', '>=', '2019-10-01 02:00:00') ('datetime', '<', '2019-11-01 02:00:00')] - November 2019 : [('datetime', '>=', '2019-11-01 01:00:00') ('datetime', '<', '2019-12-01 01:00:00')] So a record on 2019-11-01 01:30:00 would be both inside October and November. This happen because the DST is removed on happen on 27 October 2019 and this was not taken into account when computing the end of the range. With this changeset, for the given example aboth, we will have: - October 2019 : [('datetime', '>=', '2019-10-01 02:00:00') ('datetime', '<', '2019-11-01 01:00:00')] Added test without the change fails with "AssertionError: Lists differ" because: - "Q1 2019" finished on 17:00:00 instead of 16:00:00 - "Q3 2019" finished on 16:00:00 instead of 17:00:00 opw-2278829 closes #54056 closes odoo/odoo#54345 Note: maxDiff added for test to work in 13.0 X-original-commit: af5d03de28fa300ebbaa37a3d226b41051ebdf0f Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Diffstat (limited to 'odoo/models.py')
-rw-r--r--odoo/models.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/odoo/models.py b/odoo/models.py
index 99a45c0de00..4f47b169672 100644
--- a/odoo/models.py
+++ b/odoo/models.py
@@ -2104,6 +2104,8 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
if gb['tz_convert']:
tzinfo = range_start.tzinfo
range_start = range_start.astimezone(pytz.utc)
+ # take into account possible hour change between start and end
+ range_end = tzinfo.localize(range_end.replace(tzinfo=None))
range_end = range_end.astimezone(pytz.utc)
range_start = range_start.strftime(fmt)