Ir al contenido
Odoo Menú
  • Identificarse
  • Pruébalo gratis
  • Aplicaciones
    Finanzas
    • Contabilidad
    • Facturación
    • Gastos
    • Hoja de cálculo (BI)
    • Documentos
    • Firma electrónica
    Ventas
    • CRM
    • Ventas
    • TPV para tiendas
    • TPV para restaurantes
    • Suscripciones
    • Alquiler
    Sitios web
    • Creador de sitios web
    • Comercio electrónico
    • Blog
    • Foro
    • Chat en directo
    • eLearning
    Cadena de suministro
    • Inventario
    • Fabricación
    • PLM
    • Compra
    • Mantenimiento
    • Calidad
    Recursos Humanos
    • Empleados
    • Reclutamiento
    • Ausencias
    • Evaluación
    • Referencias
    • Flota
    Marketing
    • Marketing social
    • Marketing por correo electrónico
    • Marketing por SMS
    • Eventos
    • Automatización de marketing
    • Encuestas
    Servicios
    • Proyecto
    • Partes de horas
    • Servicio de campo
    • Servicio de asistencia
    • Planificación
    • Citas
    Productividad
    • Conversaciones
    • Aprobaciones
    • IoT
    • VoIP
    • Conocimientos
    • WhatsApp
    Aplicaciones de terceros Studio de Odoo Plataforma de Odoo Cloud
  • Industrias
    Comercio al por menor
    • Librería
    • Tienda de ropa
    • Tienda de muebles
    • Tienda de ultramarinos
    • Ferretería
    • Juguetería
    Alimentación y hostelería
    • Bar y taberna
    • Restaurante
    • Comida rápida
    • Casa de huéspedes
    • Distribuidor de bebidas
    • Hotel
    Inmueble
    • Agencia inmobiliaria
    • Estudio de arquitectura
    • Construcción
    • Gestión inmobiliaria
    • Jardinería
    • Asociación de propietarios
    Consultoría
    • Empresa contable
    • Partner de Odoo
    • Agencia de marketing
    • Bufete de abogados
    • Adquisición de talentos
    • Auditorías y certificaciones
    Fabricación
    • Textil
    • Metal
    • Muebles
    • Alimentos
    • Brewery
    • Regalos de empresas
    Salud y bienestar
    • Club deportivo
    • Óptica
    • Gimnasio
    • Terapeutas
    • Farmacia
    • Peluquería
    Oficios
    • Handyman
    • Hardware y asistencia informática
    • Sistemas de energía solar
    • Zapatero
    • Servicios de limpieza
    • Servicios de calefacción, ventilación y aire acondicionado
    Otros
    • Organización sin ánimo de lucro
    • Agencia de protección del medio ambiente
    • Alquiler de paneles publicitarios
    • Estudio fotográfico
    • Alquiler de bicicletas
    • Distribuidor de software
    Browse all Industries
  • Comunidad
    Aprender
    • Tutoriales
    • Documentación
    • Certificaciones
    • Formación
    • Blog
    • Podcast
    Potenciar la educación
    • Programa de formación
    • Scale Up! El juego empresarial
    • Visita Odoo
    Obtener el software
    • Descargar
    • Comparar ediciones
    • Versiones
    Colaborar
    • GitHub
    • Foro
    • Eventos
    • Traducciones
    • Convertirse en partner
    • Services for Partners
    • Registrar tu empresa contable
    Obtener servicios
    • Encontrar un partner
    • Encontrar un asesor fiscal
    • Contacta con un experto
    • Servicios de implementación
    • Referencias de clientes
    • Ayuda
    • Actualizaciones
    GitHub YouTube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Solicitar una demostración
  • Precios
  • Ayuda

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Contabilidad
  • Inventario
  • PoS
  • Proyecto
  • MRP
All apps
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Debe estar registrado para interactuar con la comunidad.
Todas las publicaciones Personas Insignias
Etiquetas (Ver todo)
odoo accounting v14 pos v15
Acerca de este foro
Ayuda

How to get information from the body of an email for a lead

Suscribirse

Reciba una notificación cuando haya actividad en esta publicación

Se marcó esta pregunta
emailleadslead
1 Responder
9859 Vistas
Avatar
Jayne Taylor

I have my incoming email server set up to create a new lead when an email is sent to a particular address.  How do I get access to the body of the email so I can populate other fields in the lead?

I assume that I should create a server action and write some python code to parse the body of the email. When you create the server action you fill in a base model. For me "crm.lead."  This model does not seem to have access to the email that is being used to create the lead.  Can anyone point me in the right direction?


1
Avatar
Descartar
Avatar
Nathan Reid
Mejor respuesta

I came up with the following for Odoo9.

It parses the incoming email (and the Notes field in the Lead or Opportunity form) and populates the respective fields.

There are a couple of things hard coded in for my specific application (user, campaign etc.).

I have 2 web forms sending content to an email address, both with slightly different formatting so the Action parses them differently.

If there's nothing in the Notes field, it will search the mail_message table for an email with the same resource id and parse the body of that instead. If you use it as a Server Action when the lead is created there should only be one matching email.

It's not bulletproof and there may be better ways to do this but it works for me and could be a start for you...


 def parse_description(description):
  fields=['Name','Contact Number','Email']
  pdict={}
  split=description.splitlines()
  for line in split:
    for field in fields:
        if field in line:
            split_line=line.split(':')
            if len(split_line)>1:
                pdict[field]=split_line[1]
  return  pdict

def parse_description_contact(description):
  fields=['Name','Contact Number','Email']
  pdict={}
  split=description.splitlines()
  for line in split:
    for field in fields:
        if field in line:
            next_line=split.index(field)+1
            if split[next_line]:
                pdict[field]=split[next_line]
  return  pdict

campaign=0
lead=self.browse(cr,uid,context['active_id'],context=context)
description=lead['description']

# GET CONTENTS OF EMAIL from mail_message IF NOTHING IS IN DESCRIPTION
 if not description:
  activeid=lead['id']
  mailcontent = env['mail.message'].search([('res_id','=',activeid),('message_type','=','email')])
  description=mailcontent['body']

if description:
    if "Contact Us" in description:
        campaign=68
        ddict=parse_description_contact(description)
    if "Budget Estimator" in description:
        campaign=69
        ddict=parse_description(description)
    if campaign:
        #self.write(cr,uid,context['active_id'],{'campaign_id':campaign})
        self.write(cr,uid,context['active_id'],{
                        'user_id':37,
                        'partner_id':None,
                        'name':ddict.get('Name'),
                        'partner_name':ddict.get('Name'),
                        'contact_name':ddict.get('Name'),
                        'phone':ddict.get('Contact Number'),
                        'mobile':ddict.get('Contact Number'),
                        'email_from':ddict.get('Email'),
                        'type':'lead',
                        'campaign_id':campaign,
                        'stage_id':''})

1
Avatar
Descartar
¿Le interesa esta conversación? ¡Participe en ella!

Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.

Inscribirse
Publicaciones relacionadas Respuestas Vistas Actividad
CAN I CONFIGURE DIFFERENT OUTGOING EMAILS?
email leads
Avatar
0
ago 22
2719
How to associate an inbound email with a contact?
email leads
Avatar
Avatar
Avatar
3
mar 15
4959
How to ignore certain email addresses when creating a lead?
email lead
Avatar
0
mar 15
4668
How to segment leads with questionnaires?
leads lead
Avatar
0
mar 15
4602
Odoo 9: Leads / Opportunities from incoming emails -- for Sales Teams Aliases
opportunities email leads lead incoming
Avatar
0
jul 16
4529
Comunidad
  • Tutoriales
  • Documentación
  • Foro
Código abierto
  • Descargar
  • GitHub
  • Runbot
  • Traducciones
Servicios
  • Alojamiento Odoo.sh
  • Ayuda
  • Actualizar
  • Desarrollos personalizados
  • Educación
  • Encontrar un asesor fiscal
  • Encontrar un partner
  • Convertirse en partner
Sobre nosotros
  • Nuestra empresa
  • Activos de marca
  • Contacta con nosotros
  • Puestos de trabajo
  • Eventos
  • Podcast
  • Blog
  • Clientes
  • Información legal • Privacidad
  • Seguridad
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo es un conjunto de aplicaciones de código abierto que cubren todas las necesidades de tu empresa: CRM, comercio electrónico, contabilidad, inventario, punto de venta, gestión de proyectos, etc.

La propuesta única de valor de Odoo es ser muy fácil de usar y totalmente integrado.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now