fix: keep bot presence online for 24h instead of racing the 30s timer
Set last_poll and last_presence 24h ahead when the service is confirmed online, so status stays 'online' until the cron explicitly marks it down. The previous 10min offset still expired between cron runs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -175,12 +175,11 @@ class AbAiBot(models.Model):
|
||||
Presence = self.env['bus.presence']
|
||||
now = fields.Datetime.now()
|
||||
# bus.presence.status is a computed field — write only last_poll/last_presence.
|
||||
# When online: set last_poll 10min ahead so the bot stays "online" across
|
||||
# the full cron cycle (Odoo cron scheduler fires every ~5min in practice).
|
||||
# When offline: set last_poll an hour in the past to force "offline" state.
|
||||
# When online: set both 24h ahead so the bot stays "online" regardless of
|
||||
# cron timing. The cron explicitly marks offline by setting them to the past.
|
||||
if online:
|
||||
poll_time = now + timedelta(minutes=10)
|
||||
presence_time = now
|
||||
poll_time = now + timedelta(hours=24)
|
||||
presence_time = now + timedelta(hours=24)
|
||||
else:
|
||||
poll_time = now - timedelta(hours=1)
|
||||
presence_time = now - timedelta(hours=1)
|
||||
|
||||
Reference in New Issue
Block a user