Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

How to get the visitor ip address in odoo 8

ip
By
aneesh ATEES Infomedia Pvt Ltd
on 11/21/16, 2:35 AM 152 views

Am trying to track the visitor ip address ,but am failed to  implement it..please help me...Urgent.

0

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
2988
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


Ahmed M.Elmubarak
On 11/21/16, 4:15 AM

Hi,

You can try the below code:

if "HTTP_X_FORWARDED_FOR" in request.httprequest.environ:
    # Virtual host
    ip = request.httprequest.environ["HTTP_X_FORWARDED_FOR"]
elif "HTTP_HOST" in request.httprequest.environ:
    # Non-virtualhost
    ip = request.httprequest.environ["REMOTE_ADDR"]


Hope this could helps

I got Exception 'object unbound'

aneesh ATEES Infomedia Pvt Ltd
on 11/21/16, 4:34 AM

Can you paste your code ..

Ahmed M.Elmubarak
on 11/21/16, 5:43 AM

from openerp.http import request

def git_ip():

ipnew = request.httprequest.headers.environ['REMOTE_ADDR']

return ipnew

aneesh ATEES Infomedia Pvt Ltd
on 11/22/16, 12:29 PM

from openerp.http import request

ipnew = request.httprequest.headers.environ['REMOTE_ADDR']

return ipnew

aneesh ATEES Infomedia Pvt Ltd
on 11/22/16, 12:34 PM

from openerp.http import request

def get_ip():

ipnew = request.httprequest.environ['REMOTE_ADDR']

return ipnew

aneesh ATEES Infomedia Pvt Ltd
on 11/22/16, 12:37 PM

May be you're missing @http.rout decorator. Btw from where you're calling your method ?

Ahmed M.Elmubarak
on 11/23/16, 5:46 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/21/16, 2:35 AM
Seen: 152 times
Last updated: 11/24/16, 1:02 AM