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

How can I  run a code block on every request a website user makes. Let's say I want to pre-select the pricelist based on the user ip, how do I run a pre-controller hook or middleware?

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

request dispatch method will call on every request 
https://github.com/odoo/odoo/blob/14.0/odoo/http.py#L1306

you can override the despatch for both http or json request 

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

@Ravi Gadhia

Thank you so much!!! I had to monkey patch the whole  HttpRequest class, but it was worth it. You have no idea how helpful it was.

PS: I do not have enough karma to mark this as solved. 😒 

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ส.ค. 22
2980
2
ม.ค. 18
4644
2
ส.ค. 25
411
5
ส.ค. 25
9965
Carrusel en sitios web แก้ไขแล้ว
2
ก.ค. 25
1025