Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FW][FIX] models.py: group by date with DST change #54345

Conversation

fw-bot
Copy link
Contributor

@fw-bot fw-bot commented Jul 10, 2020

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

Forward-Port-Of: #54189
Forward-Port-Of: #54056

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 odoo#54056

Note: maxDiff added for test to work in 13.0
X-original-commit: af5d03d
@robodoo robodoo added forwardport This PR was created by @fw-bot seen 🙂 labels Jul 10, 2020
@fw-bot
Copy link
Contributor Author

fw-bot commented Jul 10, 2020

Ping @nle-odoo
This PR targets master and is the last of the forward-port chain containing:

To merge the full chain, say

@fw-bot r+

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

@nle-odoo
Copy link
Contributor

fw-bot r+

@C3POdoo C3POdoo added the OE the report is linked to a support ticket (opw-...) label Jul 10, 2020
@robodoo robodoo added the CI 🤖 Robodoo has seen passing statuses label Jul 10, 2020
robodoo pushed a commit that referenced this pull request Jul 10, 2020
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 #54345

Note: maxDiff added for test to work in 13.0
X-original-commit: af5d03d
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
@robodoo robodoo closed this Jul 10, 2020
@robodoo robodoo temporarily deployed to merge July 10, 2020 16:34 Inactive
@fw-bot fw-bot deleted the master-12.0-models-py-opw-2278829-nle-D9qX-fw branch July 24, 2020 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI 🤖 Robodoo has seen passing statuses forwardport This PR was created by @fw-bot OE the report is linked to a support ticket (opw-...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants