From 99cc19195ac6e45476d022f3183c0df047135d6c Mon Sep 17 00:00:00 2001 From: Carlos Garcia Date: Tue, 19 May 2026 16:06:08 -0400 Subject: [PATCH] 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 --- addons/activeblue_ai/models/ab_ai_bot.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/activeblue_ai/models/ab_ai_bot.py b/addons/activeblue_ai/models/ab_ai_bot.py index f8e50a7..93d6740 100644 --- a/addons/activeblue_ai/models/ab_ai_bot.py +++ b/addons/activeblue_ai/models/ab_ai_bot.py @@ -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)