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

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
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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.


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

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

Hope it helps.

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Purpose of Closed in CRM แก้ไขแล้ว
1
ก.ค. 24
1781
2
ก.ย. 25
1446
1
ส.ค. 25
625
1
ต.ค. 24
1747
0
มิ.ย. 24
1826