I've created a dashboard item that's supposed to show the number of currently logged-in users. Here's the code I'm using to retrieve this information:
online_users = self.env['res.users'].search_count([('im_status', '=', 'online')])
However, the number returned is surprisingly high. It seems that once a user has logged in, they remain marked as "online".
What's the correct way to get the actual number of currently logged-in users? I'm using Odoo Community 18.