Skip to Content
Menu
This question has been flagged
2 Replies
6317 Views

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?

Avatar
Discard
Best Answer

Hi Utsav,
I hope this app will be help full for you,

https://apps.odoo.com/apps/modules/13.0/restrict_logins/
Thanks

Avatar
Discard
Best Answer

Hello Utsav, 


In Odoo Inside "OpenERPSession" class there is method "authenticate"

Whenever user log-in and logout from his/her Odoo then the message triggers. 

For method please refer to this link

https://github.com/odoo/odoo/blob/13.0/odoo/http.py#L989 


You can also look at the following module

https://store.webkul.com/Odoo-User-Login-Security.html 


Thanks

Anisha Bahukhandi

Technical Content Writer

Avatar
Discard
Related Posts Replies Views Activity
1
Aug 23
1644
0
Aug 23
1346
1
Aug 23
635
2
Mar 15
7364
2
Jul 24
203