| 1 | # -*- coding: utf-8 -*- |
| 2 | import json |
| 3 | |
| 4 | from odoo import http |
| 5 | from odoo.addons.website.controllers.form import WebsiteForm |
| 6 | from odoo.http import request |
| 7 | |
| 8 | |
| 9 | class ContactController(WebsiteForm): |
| 10 | |
| 11 | def _handle_website_form(self, model_name, **kwargs): |
| 12 | if model_name == 'crm.lead': |
| 13 | # Add the ip_address to the request in order to add this to the lead |
| 14 | # that will be created. With this, we avoid to create a lead from |
| 15 | # reveal if a lead is already created from the contact form. |
| 16 | request.params['reveal_ip'] = request.httprequest.remote_addr |
| 17 | |
| 18 | return super(ContactController, self)._handle_website_form(model_name, **kwargs) |