fix: override bus.presence._compute_status so bot shows online

Odoo 18's _compute_status treats future last_poll as MORE disconnected
(absolute delta). Override forces status='online' when last_poll > now,
which is set 24h ahead by _sync_bot_user_presence when the health check
passes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Carlos Garcia
2026-05-19 16:27:40 -04:00
parent eeea45b37f
commit 160f96a549

View File

@@ -186,3 +186,14 @@ class AbAiBot(models.Model):
Presence.sudo().create(vals)
except Exception as exc:
_logger.warning('Could not update bot user presence: %s', exc)
class BusPresenceBot(models.Model):
_inherit = 'bus.presence'
def _compute_status(self):
super()._compute_status()
now = fields.Datetime.now()
for record in self:
if record.last_poll and record.last_poll > now:
record.status = 'online'