[IMP] res_partner: use tools.email_split instead of custom regex when parsing partner_name to find an email.

bzr revid: tde@openerp.com-20130313105640-r53xueaz36zw3fjd
This commit is contained in:
Thibault Delavallée 2013-03-13 11:56:40 +01:00
parent 6972079a10
commit 910f7097ba
1 changed files with 4 additions and 4 deletions

View File

@ -417,10 +417,10 @@ class res_partner(osv.osv, format_address):
""" Supported syntax:
- 'Raoul <raoul@grosbedon.fr>': will find name and email address
- otherwise: default, everything is set as the name """
match = re.search(r'([^\s,<@]+@[^>\s,]+)', text)
if match:
email = match.group(1)
name = text[:text.index(email)].replace('"','').replace('<','').strip()
emails = tools.email_split(text)
if emails:
email = emails[0]
name = text[:text.index(email)].replace('"', '').replace('<', '').strip()
else:
name, email = text, ''
return name, email