In openerp to disconnect user and show the massage that user is disconnected and users having to old last_pool and search the limit date and write the status presences when presences is offline.
use this function .py file show in given below,
@api.model
def check_users_disconnection(self):
limit_date = (datetime.datetime.utcnow() - datetime.timedelta(0, DISCONNECTION_TIMER)).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
presences = self.search([('last_poll', '<', limit_date), ('status', '!=', 'offline')])
presences.write({'status': 'offline'})
notifications = []
for presence in presences:
notifications.append([(self._cr.dbname, 'bus.presence'), {'id': presence.user_id.id, 'im_status': presence.status}])
self.env['bus.bus'].sendmany(notifications)
0 Comment(s)