تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3 الردود
10406 أدوات العرض

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
فبراير 23
42888
0
يوليو 17
3161
4
سبتمبر 21
10694
2
أغسطس 20
8031
1
يونيو 24
1533