Odoo Help


how to get openerp client IP

on 1/28/15, 8:40 AM 2,541 views

I want to get openerp user client ip address, and in my module add some code copy from web module, as below:

def _get_ipaddress(self, req,httprequest, environ):
        wsgienv = req.httprequest.environ
        env = dict(
        _logger.log("env:%d", env)
        return True

But get Error​:AttributeError: 'cursor' object has no attribute 'httprequest'


where params come from : req, httprequest and environ ? Method are called by default with : cr, uid, context where : cr -- database cursor | uid -- current user id | context (dictionary) -- context arguments, like lang, time zone Synthax OLD API = https://doc.odoo.com/v6.0/developer/2_5_Objects_Fields_Methods/methods.html/ But if you start, try to use new api : https://www.odoo.com/documentation/8.0

Jérémy Kersten (jke)
on 1/29/15, 7:22 AM

Not tested, but it should works:

You can add import:

from openerp.http import request

And change your function _get_ipaddress with:

    def _get_ipaddress(self, cr, uid, context=None):
        return request.httprequest.environ['REMOTE_ADDR'] 


Also fir you information, you don't need to specify the size... It has been deprecated in v8.

        'ip_address' : fields.char('IP Address', readonly=True),




If you start with Odoo, Take an eye on https://www.odoo.com/documentation/8.0/howtos/backend.html


Good luck 

Great solution Jérémy. Accepted & upvoted :)

on 1/29/15, 7:23 AM
Ludo - Neobis
On 1/29/15, 4:18 AM

It seems this method is still using the old ORM. In that case, the signature of the method would start with something like "(self,cr,uid, etc etc.)". The "cr" or "cursor" being the first argument.

In your code, req is apparantly seen as the cursor and therefore Odoo is unable to find the attribute on that cursor.

Make sure that you use the right way (OSV vs Models)  and/or check the signature for your method.

plss help iam new to openerp

on 1/29/15, 4:40 AM
On 1/29/15, 6:30 AM

class hr_attendence(osv.osv):

    def _get_ipaddress(self,cr, uid,context=None):
        wsgienv = cr.httprequest.environ
        env = dict(
        _logger.log("env:%d", env)
        return True
    _inherit = 'hr.attendance'

    _columns = {
    #'ipaddress':fields.char('ip Address')
           'ip_address' : fields.char('IP Address', readonly=True, size=64)

    _defaults = {
        'ip_address': _get_ipaddress,


*getting same error*

* * AttributeError: 'cursor' object has no attribute 'httprequest'

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

3 follower(s)


Asked: 1/28/15, 8:40 AM
Seen: 2541 times
Last updated: 1/12/16, 2:20 AM