improved lead creation
This commit is contained in:
parent
5426b0678e
commit
f22cb7d5d0
3 changed files with 21 additions and 11 deletions
|
@ -35,6 +35,14 @@ spec:
|
|||
value: /data/servala.db
|
||||
- name: ODOO_URL
|
||||
value: https://test.central.vshn.ch
|
||||
- name: ODOO_LEAD_CAMPAIGN_ID
|
||||
value: "6"
|
||||
- name: ODOO_LEAD_SOURCE_ID
|
||||
value: "28"
|
||||
- name: ODOO_LEAD_MEDIUM_ID
|
||||
value: "1"
|
||||
- name: ODOO_LEAD_TAG_ID
|
||||
value: "6"
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: servala
|
||||
|
|
|
@ -13,7 +13,7 @@ class OdooAPI:
|
|||
self._connect()
|
||||
|
||||
def _connect(self):
|
||||
"""Establish connection to Odoo with detailed error logging"""
|
||||
"""Establish connection to Odoo"""
|
||||
try:
|
||||
# Parse URL to get host
|
||||
url = settings.ODOO_CONFIG["url"]
|
||||
|
@ -54,7 +54,7 @@ class OdooAPI:
|
|||
raise
|
||||
|
||||
def create_lead(self, lead):
|
||||
"""Create a lead in Odoo with detailed logging"""
|
||||
"""Create a lead in Odoo"""
|
||||
try:
|
||||
logger.info(
|
||||
f"Attempting to create lead for {lead.name} from {lead.company}"
|
||||
|
@ -71,23 +71,22 @@ class OdooAPI:
|
|||
service_details.append(f"Service: {lead.service.name}")
|
||||
if provider_name:
|
||||
service_details.append(f"Provider: {provider_name}")
|
||||
if lead.service.categories.exists():
|
||||
categories = ", ".join(
|
||||
cat.name for cat in lead.service.categories.all()
|
||||
)
|
||||
service_details.append(f"Categories: {categories}")
|
||||
if lead.plan:
|
||||
service_details.append(f"Plan: {lead.plan.name}")
|
||||
|
||||
# Prepare lead data
|
||||
lead_data = {
|
||||
"name": f"Interest in {lead.service.name}",
|
||||
"name": f"Servala - Interest in {lead.service.name}",
|
||||
"contact_name": lead.name,
|
||||
"partner_name": lead.company,
|
||||
"email_from": lead.email,
|
||||
"phone": lead.phone,
|
||||
"description": "\n".join(service_details),
|
||||
"description": "<br/>".join(service_details),
|
||||
"type": "lead",
|
||||
"campaign_id": settings.ODOO_CONFIG["campaign_id"],
|
||||
"source_id": settings.ODOO_CONFIG["source_id"],
|
||||
"medium_id": settings.ODOO_CONFIG["medium_id"],
|
||||
"tag_ids": [(4, settings.ODOO_CONFIG["tag_id"])],
|
||||
}
|
||||
|
||||
logger.debug(f"Prepared lead data: {lead_data}")
|
||||
|
@ -106,7 +105,7 @@ class OdooAPI:
|
|||
message_data = {
|
||||
"body": f"""
|
||||
<p>Thank you for your interest in the service <strong>{lead.service.name}</strong>.
|
||||
We recorded the following information and will get back to you soon.</p>
|
||||
We recorded the following information and will get back to you soon.</p><br/>
|
||||
|
||||
<p>Contact Details:</p>
|
||||
<ul>
|
||||
|
@ -121,7 +120,6 @@ class OdooAPI:
|
|||
<li><strong>Service:</strong> {lead.service.name}</li>
|
||||
{f'<li><strong>Provider:</strong> {provider_name}</li>' if provider_name else ''}
|
||||
{f'<li><strong>Plan:</strong> {lead.plan.name}</li>' if lead.plan else ''}
|
||||
<li><strong>Categories:</strong> {', '.join(cat.name for cat in lead.service.categories.all())}</li>
|
||||
</ul>
|
||||
""",
|
||||
"message_type": "comment",
|
||||
|
|
|
@ -174,6 +174,10 @@ ODOO_CONFIG = {
|
|||
"db": env.str("ODOO_DB", default="odoo"),
|
||||
"username": env.str("ODOO_USERNAME", default="odoo"),
|
||||
"password": env.str("ODOO_PASSWORD", default="odoo"),
|
||||
"campaign_id": env.str("ODOO_LEAD_CAMPAIGN_ID", default="1"),
|
||||
"source_id": env.str("ODOO_LEAD_SOURCE_ID", default="1"),
|
||||
"medium_id": env.str("ODOO_LEAD_MEDIUM_ID", default="1"),
|
||||
"tag_id": env.str("ODOO_LEAD_TAG_ID", default="1"),
|
||||
}
|
||||
|
||||
BROKER_USERNAME = env.str("BROKER_USERNAME", default="broker")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue