تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
9 الردود
14688 أدوات العرض

from openerp.http import request

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

except Exception as e:
    print " Exception on request ",e

    pass

الصورة الرمزية
إهمال
الكاتب أفضل إجابة

issue solved environ = request.httprequest.headers.environ

print environ.get("REMOTE_ADDR") need to put inside the function instead of class header

الصورة الرمزية
إهمال
أفضل إجابة

Actually I don't know more aboute REMOTE_ADDR

But this is possible

from openerp.http import request
environ = request.httprequest.headers.environ
print environ.get("REMOTE_ADDR")

My output

127.0.0.1

May help you

الصورة الرمزية
إهمال
الكاتب

I am still getting Exception object Unbound

I tested this inside a compute function

it is working

الكاتب

can you provide that sample code

class Foo(models.Model):

____@api.one

____def _compute_progress(self):

________self.progress = lib.progress_by_state(self)

________from openerp.http import request

________environ = request.httprequest.headers.environ

________print environ.get("REMOTE_ADDR")

don't look first line of function

الكاتب

still i get excception of object unbound

المنشورات ذات الصلة الردود أدوات العرض النشاط
1
يونيو 24
1547
1
أغسطس 25
199
4
مارس 25
42172
1
أبريل 23
2473
3
مايو 24
6370