Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odpovědi
10425 Zobrazení

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?

Avatar
Zrušit
Nejlepší odpověď
What's the need to del env? anyway you can access env by request.env or request.httprequest.environ
Avatar
Zrušit
Nejlepší odpověď

Add this importation please, to use request.env

from odoo.http import request
Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
4
úno 23
42905
0
čvc 17
3172
4
zář 21
10707
2
srp 20
8035
1
čvn 24
1535