Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

action server with python to parse incoming emails for lead creation

By
A
on 7/23/13, 10:32 PM 1,209 views

I'm using a web form that sends an email which is turned into a lead. The leads don't automatically parse the email and sort the name/phone/etc. into their corresponding fields. How can I use python to create an action server that does this?

I found a python example from another thread that doesn't seem to work so far:

def parse_description(description):
  '''
   there is parse function
   It is example for parsing messages like this:

   Name: John
   Phone: +100500
  '''
  fields=['Name','Phone']
  _dict={}
  description=description.lower()
  for line in description.split('\n'):
    for field in fields:
        if field in line:
            split_line=line.split(':')
            if len(split_line)>1:
                pre_dict[field]=line.split(':')[1]
  return  dict

lead=self.browse(cr,uid,context['active_id'],context=context)
description=lead['description']
_dict=parse_description(description)
self.write(cr,uid,context['active_id'],{
                        'partner_name':_dict.get('name'),
                        'contact_name':_dict.get('name'),
                        'phone':_dict.get(u'phone'),
                        'mobile':_dict.get(u'phone')})

Did you ever get an answer to this? I am having the same issue!

Jayne Taylor
on 10/28/15, 6:05 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 7/23/13, 10:32 PM
Seen: 1209 times
Last updated: 10/28/15, 6:05 AM