İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
185 Görünümler

I would like to capture the vistors/leads locations (city, country ).
When the visitor submit any forms in website, CRM leads capture should automatically identify the location and store it in address fields .

 I want a clean, supported way to do this in Odoo 18 or 19.

Goal

  • Read the visitor IP from the request
  • Add it as a field on crm.lead
  • Save it during website form submit
  • Keep the default website_form behavior if possible
Avatar
Vazgeç
En İyi Yanıt

Hi,

To capture a visitor’s IP address and location in CRM leads from a website form in Odoo 18 or 19, you can achieve it cleanly by inheriting the website_form controller instead of modifying core code. In your custom module, extend the _handle_website_form method from website_form.controllers.main.WebsiteForm to read the visitor’s IP using request.httprequest.remote_addr, then optionally use an external API (like ipapi.co) to resolve it into city and country. Before calling super(), add these values (e.g., visitor_ip, visitor_city, visitor_country) into the kwargs dictionary so they’re saved automatically on the created crm.lead record. Finally, define matching fields in the crm.lead model to store the captured data.


Hope it helps.


Avatar
Vazgeç
En İyi Yanıt

Hello,
You can catch the visitor IP using:
request.httprequest.environ.get('REMOTE_ADDR')

Hope it helps.

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Tem 24
1789
2
Eyl 25
1449
1
Ağu 25
629
1
Eki 24
1753
0
Haz 24
1831