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.

2

how to get user ip address?

v7 ip
By
jerry79
on 7/24/13, 1:11 PM 4,540 views

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

1

Daniel Reis

--Daniel Reis--
3436
| 6 7 9
Lisbon, Portugal
--Daniel Reis--

Author of the "Odoo Development Essentials" book.

Applications Manager at Securitas Portugal

Github: https://github.com/dreispt

Twitter; @reis_pt


Daniel Reis
On 7/25/13, 7:25 AM

Use a web server upfront and check it's log.

I use nginx upfront, as a reverse proxy for OpenERP, so that is's accessed through HTTPS. Looking through nginx's log I'm able to check client IP addresses and the signatures for the browsers used.

thanks very much.

jerry79
on 7/25/13, 7:42 AM

I have not use nginx and I search the default oe log file, find must set log_level is debug_rpc_answer then can show the IP. so if have other method can get the IP? thanks

jerry79
on 7/25/13, 7:48 AM
0
Ahad Pashaeeian
On 8/26/15, 4:41 AM

https://www.odoo.com/forum/help-1/question/how-to-get-openerp-client-ip-74427

0
klacus
On 12/10/13, 6:08 AM

Hello. may the best way to modify http.py

looking for : class WebRequest(object):

    def init(self, params):
    self.params = dict(params)
    # OpenERP session setup
    self.session_id = self.params.pop("session_id", None) or uuid.uuid4().hex
    self.session = self.httpsession.get(self.session_id)
    if not self.session:
        self.httpsession[self.session_id] = self.session = session.OpenERPSession()
    self.session.config = self.config
    self.context = self.params.pop('context', None)
    #-----------------------------------------------------------------
    # add client ip to context
    if type(self.context) == dict:
            self.context['remote_addr'] = self.httprequest.remote_addr
    # ----------------------------------------------------------------               
    self.debug = self.params.pop('debug', False) != False

It's work for me on 6.1 Bye.

Thank Buddy.. But how i use in my own py file or can we add it context dictionary, the main purpose is to store the client ip address in db for every transaction

khudrath ali baig
on 1/18/14, 3:14 AM
  • in xml file --------------------------------

<script> $(document).ready(function(){ $(document).delegate(".oe_form_button_edit , .oe_list_add , .oe_form_button_create ",'click',function() { ipfill(); });

function ipfill() { $.getJSON("http://smart-ip.net/geoip-json?callback=?", function(data){ $('.ipcaptuaring').children().val(data.host); }); } ipfill(); }); </script>

<field name="ipaddress" class="ipcaptuaring"/>

  • in py file -----------------------------------

'ipaddress':fields.char('ip Address')

khudrath ali baig
on 1/18/14, 8:14 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

3 follower(s)

Stats

Asked: 7/24/13, 1:11 PM
Seen: 4540 times
Last updated: 8/26/15, 4:41 AM