Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
9 Odpowiedzi
14635 Widoki

from openerp.http import request

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

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

    pass

Awatar
Odrzuć
Autor Najlepsza odpowiedź

issue solved environ = request.httprequest.headers.environ

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

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

I am still getting Exception object Unbound

I tested this inside a compute function

it is working

Autor

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

Autor

still i get excception of object unbound

Powiązane posty Odpowiedzi Widoki Czynność
1
cze 24
1532
1
sie 25
118
4
mar 25
42069
1
kwi 23
2432
3
maj 24
6320