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

Hi,

I'm trying to remove request._env in Odoo 12 but it gives Error:

'HttpRequest' object has no attribute '_env'

my Code :

class IrHttp(models.AbstractModel):
_inherit = "ir.http"

@classmethod
def _dispatch(cls):
if not hasattr(request, "jsonrequest"):
wsr = request.env['website.seo.redirect']
del request._env
try:
return wsr.redirect_auto()
except NoRedirectError:
try:
return cls.reroute(wsr.find_origin())
except NoOriginError:
pass

return super(IrHttp, cls)._dispatch()

any ideas of why this happens?

Awatar
Odrzuć
Najlepsza odpowiedź
What's the need to del env? anyway you can access env by request.env or request.httprequest.environ
Awatar
Odrzuć
Najlepsza odpowiedź

Add this importation please, to use request.env

from odoo.http import request
Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
4
lut 23
42897
0
lip 17
3168
4
wrz 21
10695
2
sie 20
8032
1
cze 24
1533