跳至內容
選單
此問題已被標幟
9 回覆
14645 瀏覽次數

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
6月 24
1534
1
8月 25
144
4
3月 25
42080
1
4月 23
2433
3
5月 24
6326