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

Need some help for action on incoming email

By
Benoit COVILLE
on 4/23/14, 3:53 PM 1,717 views

Hi,

I'm trying to triger an action on incoming email in OpenERP Server. I would like OpenERP to create a new lead filled with informations from the content of this email. I read some some subject about this in Q/A but didn't achieve to do this ?? I created a server action of type python code on incoming email but OpenERP only create a new lead without filling other fileds with my code. Sure, I'm not a king in python programing but perhaps someone could help me ?

Here's the code:

def parse_description(description): ''' parse function for parsing messages like this: Nom|{Nom:value} Telephone|{Telephone:value} Structure|{Structure:value} Education|{Education:value} Sante|{Sante:value} Statut|{Statut:value} lits|{lits:value} Societe|{Societe:value} poste|{poste:value} Email|{Email:value} Adresse|{Adresse:value} CP|{CP:value} Ville|{Ville:value} Objet|{Objet:value} Demande|{Demande:value} Provenance|{Provenance:value} Newsletter|{Newsletter:value} ''' fields=['Nom','Telephone','Structure','Education','Sante','Statut','lits','Societe','poste','Email','Adresse','CP','Ville','Pays','Objet','Objet_autre','Demande','Provenance','Newsletter'] _dict={} for line in description.split('\n'): for field in fields: if field in line: split_line=line.split('|') if len(split_line)>1: _dict[field]=split_line[1] return _dict lead=self.browse(cr,uid,context['active_id'],context=context) description=lead['description'] _dict=parse_description(description) ''' Mapping des champs ''' test_newsletter=_dict.get(u'Newsletter') if test_newsletter == "Abonnement lettre information": newsletter='t' else: newsletter='f' test_provenance=_dict.get('Provenance') if test_provenance == "Web": channel='1' elif test_provenance == "Courrier / pub": channel='7' elif test_provenance == "Recommandation": channel='3' elif test_provenance == "Salon / foire": channel='5' elif test_provenance == "Facebook, Twitter, ...": channel='6' elif test_provenance == "Emailing": channel='4' elif test_provenance == "Telephone": channel='2' else: channel='8' self.write(cr,uid,context['active_id'],{ 'partner_name':_dict.get('Societe'), 'contact_name':_dict.get('Nom'), 'phone':_dict.get(u'Telephone'), 'street':_dict.get(u'Adresse'), 'city':_dict.get(u'Ville'), 'channel_id':channel, 'function':_dict.get(u'poste'), 'description':_dict.get(u'Demande'), 'email_from':_dict.get(u'Email'), 'opt_out':newsletter, 'country_id':'76', 'zip':_dict.get(u'CP'), 'ref':_dict.get(u'Structure')+" "+_dict.get(u'Sante')+" "+_dict.get(u'Statut')+" "+_dict.get(u'lits'), 'name':_dict.get(u'Objet')})

Many thanks for your advices.

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

2 follower(s)

Stats

Asked: 4/23/14, 3:53 PM
Seen: 1717 times
Last updated: 8/3/16, 6:11 PM