Skip to content
Snippets Groups Projects
Commit af5d03de authored by Nicolas Lempereur's avatar Nicolas Lempereur
Browse files

[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#54189

Note: maxDiff added for test to work in 13.0
X-original-commit: df9de06d
Signed-off-by: default avatarNicolas Lempereur (nle) <nle@odoo.com>
parent 29938397
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment