Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
2429 Vizualizări

Hello,

I'm reaching out to see if it is possible to integrate an external website's contact form with Odoo. Specifically, I want to link the contact form of a website to our Odoo instance. I want to know if this is possible.



Here's the scenario: We have a website where potential clients can reach out to us through a contact form or submission form. We want to ensure that whenever someone submits a query or fills out the contact form or submission form from that external website, the information is automatically captured as a new opportunity in our Odoo CRM.


Can someone confirm if this is possible and how it can be done please?


Thank you in advance for your time and assistance.


Imagine profil
Abandonează

yes, but you need to use odoo external api.

Autor

Hello Manish,

Can you please elaborate on this please?

Cel mai bun răspuns

Hello Zuhair, 


There are two kind of solutions: 


Solution 1

import xmlrpc.client

# Odoo XML-RPC parameters
url = 'http://your-odoo-instance'
db = 'database_name'
username = 'user'
password = 'password'

# Connect to Odoo XML-RPC server
common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
uid = common.authenticate(db, username, password, {})

# Create a proxy object for the CRM module
models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))

# Create a lead in Odoo
lead_data = {
    'name': 'John Doe',
    'contact_name': 'John Doe',
    'email_from': 'john@example.com',
    'description': 'Interested in your products',
    # Add more fields as needed
}
lead_id = models.execute_kw(db, uid, password, 'crm.lead', 'create', [lead_data])

Solution 2

from odoo import http
from odoo.http import request

class ExternalFormController(http.Controller):
   
    @http.route('/your/endpoint', type='http', auth='public', methods=['POST'])
    def handle_contact_form(self, **post):
        # Extract data from the incoming request
        name = post.get('name')
        email = post.get('email')
        message = post.get('message')
       
        # Create a lead/contact in Odoo
        Lead = request.env['crm.lead']
        lead_vals = {
            'name': name,
            'contact_name': name,
            'email_from': email,
            'description': message,
            # Add more fields as needed
        }
        lead = Lead.create(lead_vals)
       
        # You may want to return a response to the external form indicating success or failure
        return "Success"  # Or you can return JSON/XML response

Thanks

Imagine profil
Abandonează
Autor Cel mai bun răspuns

Hello,

Thank you for your reponse but i don't think it is possible on Odoo Online.

Imagine profil
Abandonează

Okay, In that case, odoo online solution 1 is possible and it's tested from my side as well.

Autor

Hello Manish,

Can you tell me where this code needs to be inserted and the steps, I need to follow to complete this development?

Related Posts Răspunsuri Vizualizări Activitate
1
feb. 25
2243
1
dec. 24
2644
1
iun. 24
3412
2
apr. 24
4025
2
apr. 24
5452