Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
5488 Ansichten

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.

Avatar
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
0
Okt. 16
10247
0
März 15
4005
2
Juni 23
2644
1
Mai 22
9050
2
Juli 24
10557