Live Chat
True
FAQs
Odoo 13

How to get user ip address?

When user log in openerp use browse, I want to get his computer ip address? how to get it? pls help, I search the code two days and not result. thanks


Use this chunk of code

USER_PRIVATE_FIELDS = ['password']
@api.model
def _check_credentials(self, password):
    result = super(LoginUserDetail, self)._check_credentials(password)
    ip_address = request.httprequest.environ['REMOTE_ADDR']
    vals = {'name': self.name,
            'ip_address': ip_address
            }
    self.env['login.detail'].sudo().create(vals)
    return result


Was this article helpful?

FAQ HOME

To install this Web App in your iPhone/iPad press and then Add to Home Screen.