odoo 获取IP地址

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

posted @ 2020-02-05 16:44  那时一个人  阅读(824)  评论(0编辑  收藏  举报