Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
4 ตอบกลับ
22053 มุมมอง

I need to get current URL on button click in website. From this URL, i want to retrieve an id, so i used this code to get the URL.

"request.httprequest.url", using this code i get an id only on "Get" method, but for a "POST" method i didn't get  id.

can anyone help me to resolve this..

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi, there are some ways to do it


from odoo.http import request
from odoo import http

request.httprequest.url

request.httprequest.base_url

request.httprequest.host_url

http.request.httprequest

http.request.httprequest.full_path

base_url = self.env['ir.config_parameter'].get_param('web.base.url')




อวตาร
ละทิ้ง

What is the difference between url, base_url, host_url or etc?

>>>>>>>>>> FIELDS VIEW GET: BASE URL [http://127.0.0.3:8056] <<<<<<<<<<
>>>>>>>>>> FIELDS VIEW GET: REQ URL [http://127.0.0.3:8056/web/dataset/call_kw/purchase.request/load_views] <<<<<<<<<<
>>>>>>>>>> FIELDS VIEW GET: REQ BASE [http://127.0.0.3:8056/web/dataset/call_kw/purchase.request/load_views] <<<<<<<<<<
>>>>>>>>>> FIELDS VIEW GET: REQ HOST [http://127.0.0.3:8056/] <<<<<<<<<<
>>>>>>>>>> FIELDS VIEW GET: HTTP REQ [<Request 'http://127.0.0.3:8056/web/dataset/call_kw/purchase.request/load_views' [POST]>] <<<<<<<<<<
>>>>>>>>>> FIELDS VIEW GET: FULL PATH [/web/dataset/call_kw/purchase.request/load_views?] <<<<<<<<<<

คำตอบที่ดีที่สุด

Hello,

If you are using it in website you can access the URL request from using request.httprequest.referrer

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.พ. 25
19336
2
มิ.ย. 24
1704
1
ธ.ค. 23
1408
1
เม.ย. 23
1580
1
มี.ค. 23
2400