Thomas Lefebvre (thle) 75374ad17d [FIX] calendar: trigger activity according to timezone
Steps to reproduce:
-------------------
- be in UTC -5 (America/Lima for example)
    on the system (and so browser) and the user profile;
- create an event from 4pm to 5pm the next day;
- be at 2pm today;

Issue:
------
We have a notification in activities for this
event today, which is one day too soon.

Cause:
------
To find the events that need to be notified to the user, we use a domain which, in this case,
can be expressed as follows:
```
(
the `start` of the event must be after "now" (the event has not yet passed)
OR
the event `stop` must be after now (the event is in progress)
)
AND
the `start` of the event must be less than the end of the day (the event must be today)
```

The end of the day must be determined, but taking into account the user's timezone.
As the domain has to work with UTC values (because the `start` and `stop` values of the event are in UTC in DB),
in order to determine the end of the current day, we first need to determine which day the user is in UTC.

Logic before this commit (using the example):
```py
start_dt = datetime.datetime.utcnow() # 19:00 (because 14h in America/Lima -5)
start_date = timezone(tz).localize(start_dt).astimezone(UTC).date() # 00:00 next day
end_dt = datetime.datetime.combine(start_date, datetime.time.max) # 23:59 next day
end_dt = timezone(tz).localize(end_dt).astimezone(UTC) # 4:59 second next day
```
The result (for an America/Lima timezone) is that if the event has its `start`
in UTC before 4:59 two days later, the event will be notified.

Solution:
---------
Correct the values used to construct the domain.

Logic after this commit (using the example):
```py
start_dt_utc = now_utc.replace(tzinfo=UTC) # 19:00 (because 14h in America/Lima -5)
start_dt = start_dt_utc.astimezone(user_tz) # 14:00 (because 14h in America/Lima -5)
stop_dt = datetime.datetime.combine(start_dt.date(), datetime.time.max).replace(tzinfo=user_tz).astimezone(UTC) # 4:59 next day
```
Because 23:59 today using user timezone and then converted to UTC gives 4:59 next day.
In fact, the day of a user in the America/Lima (UTC -5) timezone ends in UTC at 4:59 the next day.

If this same user creates an event that starts at midnight (and therefore tomorrow),
the activity must not be displayed before midnight and therefore 5:00 the next day in UTC.

opw-3523558

closes odoo/odoo#144064

X-original-commit: 5a997d34f53d4b00e230b4a9d3131a015b190548
Signed-off-by: Arnaud Joset (arj) <arj@odoo.com>
Signed-off-by: Thomas Lefebvre (thle) <thle@odoo.com>
2023-11-30 11:44:51 +00:00
2023-10-27 08:36:16 +00:00
2023-11-02 21:02:44 +00:00
2023-11-20 04:58:31 +00:00
…
…
…
…

Build Status Tech Doc Help Nightly Builds

Odoo

Odoo is a suite of web based open source business apps.

The main Odoo Apps include an Open Source CRM, Website Builder, eCommerce, Warehouse Management, Project Management, Billing & Accounting, Point of Sale, Human Resources, Marketing, Manufacturing, ...

Odoo Apps can be used as stand-alone applications, but they also integrate seamlessly so you get a full-featured Open Source ERP when you install several Apps.

Getting started with Odoo

For a standard installation please follow the Setup instructions from the documentation.

To learn the software, we recommend the Odoo eLearning, or Scale-up, the business game. Developers can start with the developer tutorials

S
Description
No description provided
Readme LGPL-3.0
3.4 GiB
Languages
Python 49.6%
JavaScript 47.8%
SCSS 2%
CSS 0.3%
HTML 0.2%