[FIX] calendar: fix no last call traceback
If there was an issue an the lastcall value for the calendar cron the cron would raise an error. This commit give a default value to the lastcall equal to one week ago. task-id : 3102295 closes odoo/odoo#110154 X-original-commit: e0aa273104ce576cd2746340f0e2c5c4af4a86bd Signed-off-by: Arnaud Joset <arj@odoo.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
import logging
|
||||
from datetime import timedelta
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo.tools import plaintext2html
|
||||
@@ -150,6 +151,7 @@ class AlarmManager(models.AbstractModel):
|
||||
design. The attendees receive an invitation for any new event
|
||||
already.
|
||||
"""
|
||||
lastcall = self.env.context.get('lastcall', False) or fields.date.today() - relativedelta(weeks=1)
|
||||
self.env.cr.execute('''
|
||||
SELECT "alarm"."id", "event"."id"
|
||||
FROM "calendar_event" AS "event"
|
||||
@@ -162,7 +164,7 @@ class AlarmManager(models.AbstractModel):
|
||||
AND "event"."active"
|
||||
AND "event"."start" - CAST("alarm"."duration" || ' ' || "alarm"."interval" AS Interval) >= %s
|
||||
AND "event"."start" - CAST("alarm"."duration" || ' ' || "alarm"."interval" AS Interval) < now() at time zone 'utc'
|
||||
)''', [alarm_type, self.env.context['lastcall']])
|
||||
)''', [alarm_type, lastcall])
|
||||
|
||||
events_by_alarm = {}
|
||||
for alarm_id, event_id in self.env.cr.fetchall():
|
||||
|
||||
Reference in New Issue
Block a user