lead view update, name vs partner_name

mailgate do not depends on netsvc, don't catch exceptions silently, fix email regex (allow underscores and modern tlds)

bzr revid: al@openerp.com-20100317043034-u7pqd2f80eur286r
This commit is contained in:
Antony Lesuisse 2010-03-17 05:30:34 +01:00
parent 6b697e8569
commit b6b93ef9d0
3 changed files with 12 additions and 30 deletions

View File

@ -30,7 +30,7 @@ class crm_lead(osv.osv):
_columns = {
'categ_id': fields.many2one('crm.case.categ', 'Lead Source', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.opportunity')]"),
'type_id': fields.many2one('crm.case.resource.type', 'Lead Type', domain="[('section_id','=',section_id),('object_id.model', '=', 'crm.lead')]"),
'partner_name': fields.char("Lead Name", size=64),
'partner_name': fields.char("Contact Name", size=64),
'priority': fields.selection(crm.AVAILABLE_PRIORITIES, 'Priority'),
'date_closed': fields.datetime('Closed', readonly=True),

View File

@ -42,7 +42,7 @@
<field name="arch" type="xml">
<form string="Leads Form">
<group colspan="4" col="7">
<field name="partner_name" required="1"/>
<field name="name" required="1"/>
<field name="priority"/>
<field name="date_deadline"/>
<button
@ -57,7 +57,6 @@
<field name="user_id"/>
<field name="stage_id" widget="selection" readonly="1" domain="[('object_id.model', '=', 'crm.lead')]"/>
<group col="2" colspan="1">
<button name="stage_previous" string="Previous" states="open,pending" type="object" icon="gtk-go-back"/>
<button name="stage_next" string="Next" states="open,pending" type="object" icon="gtk-go-forward"/>
</group>
@ -66,7 +65,7 @@
<page string="Lead">
<group colspan="2" col="4">
<separator string="Contact" colspan="4" col="4"/>
<field name="name" string="Contact Name" colspan="4"/>
<field name="partner_name" string="Contact Name" colspan="4"/>
<newline/>
<field domain="[('domain', '=', 'contact')]" name="title"/>
<field name="function_name" />
@ -79,14 +78,14 @@
</group>
<group colspan="2" col="3">
<separator string="Communication" colspan="4" col="3"/>
<field name="email_from" widget="email"/>
<newline/>
<field name="phone"/>
<newline/>
<field name="fax"/>
<newline/>
<field name="mobile"/>
<newline/>
<field name="email_from" widget="email"/>
<newline/>
<separator string="Links" colspan="4" col="3"/>
<field name="partner_id"/>
<button

View File

@ -1,3 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##############################################################################
#
@ -30,14 +31,7 @@ import binascii
import time, socket
email_re = re.compile(r"""
([a-zA-Z][\w\.-]*[a-zA-Z0-9] # username part
@ # mandatory @ sign
[a-zA-Z0-9][\w\.-]* # domain must start with a letter ... Ged> why do we include a 0-9 then?
\.
[a-z]{2,3} # TLD
)
""", re.VERBOSE)
email_re = re.compile(r"([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6})")
case_re = re.compile(r"\[([0-9]+)\]", re.UNICODE)
command_re = re.compile("^Set-([a-z]+) *: *(.+)$", re.I + re.UNICODE)
reference_re = re.compile("<.*-tinycrm-(\\d+)@(.*)>", re.UNICODE)
@ -124,7 +118,7 @@ def html2plaintext(html, body_id=None, encoding='utf-8'):
html += '\n\n'
html += '[%s] %s\n' % (i+1, url)
return html
class rpc_proxy(object):
def __init__(self, uid, passwd, host='localhost', port=8069, path='object', dbname='terp'):
self.rpc = xmlrpclib.ServerProxy('http://%s:%s/xmlrpc/%s' % (host, port, path))
@ -178,11 +172,7 @@ class email_parser(object):
'user_id': False,
'description': message['body'],
}
try:
data.update(self.partner_get(self._decode_header(msg['From'])))
except Exception, e:
import netsvc
netsvc.Logger().notifyChannel('mailgate', netsvc.LOG_ERROR, "%s" % e)
data.update(self.partner_get(self._decode_header(msg['From'])))
try:
id = self.rpc(self.model, 'create', data)
@ -258,7 +248,6 @@ class email_parser(object):
message['attachment'] = attachment
#end for
return message
#end def
def msg_user(self, msg, id):
body = self.msg_body_get(msg)
@ -363,7 +352,7 @@ class email_parser(object):
if msg.get('Subject', ''):
del msg['Subject']
msg['Subject'] = '['+str(case_id)+'] '+subject
msg['Message-Id'] = '<'+str(time.time())+'-tinycrm-'+str(case_id)+'@'+socket.gethostname()+'>'
msg['Message-Id'] = '<'+str(time.time())+'-openerpcrm-'+str(case_id)+'@'+socket.gethostname()+'>'
emails = self.rpc(self.model, 'emails_get', case_id)
priority = emails[3]
@ -386,9 +375,7 @@ class email_parser(object):
if __name__ == '__main__':
import sys, optparse
parser = optparse.OptionParser(
usage='usage: %prog [options]',
version='%prog v1.0')
parser = optparse.OptionParser( usage='usage: %prog [options]', version='%prog v1.0')
group = optparse.OptionGroup(parser, "Note",
"This program parse a mail from standard input and communicate "
"with the Open ERP server for case management in the CRM module.")
@ -408,10 +395,6 @@ if __name__ == '__main__':
msg_txt = email.message_from_file(sys.stdin)
try :
parser.parse(msg_txt)
except Exception, e:
if getattr(e, 'faultCode', '') and 'Connection unexpectedly closed' in e.faultCode:
print e
parser.parse(msg_txt)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: