跳至内容
菜单
此问题已终结
3 回复
9970 查看

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?

形象
丢弃
最佳答案
What's the need to del env? anyway you can access env by request.env or request.httprequest.environ
形象
丢弃
最佳答案

Add this importation please, to use request.env

from odoo.http import request
形象
丢弃
相关帖文 回复 查看 活动
4
2月 23
41331
0
7月 17
2887
4
9月 21
10071
2
8月 20
7628
1
6月 24
1148