Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
3395 Visualizzazioni

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?

Avatar
Abbandona
Risposta migliore

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 

Avatar
Abbandona
Autore Risposta migliore

@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. 😒 

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
ago 22
3015
2
gen 18
4681
2
ago 25
544
5
ago 25
10034
2
lug 25
1072