Is there a way in which I can track when a user has logged in and logged out in Odoo 13 community edition? I tried doing this:
def check(self, db, uid, passwd):
res=super(UserInfo, self).check(db, uid, passwd)
# base_url = self.env['ir.config_parameter'].get_param('web.base.url')
# _logger.info(base_url)
req = request.httprequest
base_url = req.base_url
if base_url.split('/')[-1] == 'logout':
session_id = request.session.uid
log_id = self.env['user.session'].search([['session_id','=',session_id]])
sign_out = fields.datetime.now()
vals = {'sign_out':sign_out}
log_id.write(vals)
return res
but it does not work. Can anyone help me out?