diff options
| author | Jérémy Hennecart <jeh@odoo.com> | 2020-09-08 07:07:35 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2020-10-23 07:29:08 +0000 |
| commit | 232a3c4c65dd60215a5def010da8559a9ffb2378 (patch) | |
| tree | 4f5745512b6862987ef6f5953216875a138b524e | |
| parent | 2656b855a817e5fd9270392bbf62b3117376fa34 (diff) | |
[FIX] base,calendar: fix calendar reminder
The purpose of this commit is to have reliable calendar event reminder.
Before, the reminders was not send directly and was instead put in mailing
queue, which was leading to some delay. This is due do mail_notify_force_send
context key being force to False when being in cron mode. However here we
do not want to have calendar cron scheduling emails, then mailing cron
sending them as it implies two delays.
In order to try to send reminder mails as soon as possible compared to their
schedule let us send mails directly during the calendar cron.
Task ID-2331999
closes odoo/odoo#57994
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
| -rw-r--r-- | addons/calendar/models/calendar_alarm_manager.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/addons/calendar/models/calendar_alarm_manager.py b/addons/calendar/models/calendar_alarm_manager.py index 2fb8ca1d099..83cdd1add40 100644 --- a/addons/calendar/models/calendar_alarm_manager.py +++ b/addons/calendar/models/calendar_alarm_manager.py @@ -115,10 +115,10 @@ class AlarmManager(models.AbstractModel): """ result = [] # TODO: remove event_maxdelta and if using it - if one_date - timedelta(minutes=(missing and 0 or event_maxdelta)) < fields.Datetime.now() + timedelta(seconds=in_the_next_X_seconds): # if an alarm is possible for this date + if one_date - timedelta(minutes=(missing * event_maxdelta)) < fields.Datetime.now() + timedelta(seconds=in_the_next_X_seconds): # if an alarm is possible for this date for alarm in event.alarm_ids: if alarm.alarm_type == alarm_type and \ - one_date - timedelta(minutes=(missing and 0 or alarm.duration_minutes)) < fields.Datetime.now() + timedelta(seconds=in_the_next_X_seconds) and \ + one_date - timedelta(minutes=(missing * alarm.duration_minutes)) < fields.Datetime.now() + timedelta(seconds=in_the_next_X_seconds) and \ (not after or one_date - timedelta(minutes=alarm.duration_minutes) > fields.Datetime.from_string(after)): alert = { 'alarm_id': alarm.id, @@ -134,6 +134,7 @@ class AlarmManager(models.AbstractModel): @api.model def _get_partner_next_mail(self, partners=None): + self = self.with_context(mail_notify_force_send=True) last_notif_mail = fields.Datetime.to_string(self.env.context.get('lastcall') or fields.Datetime.now()) cron = self.env.ref('calendar.ir_cron_scheduler_alarm', raise_if_not_found=False) |
