Skip to content
Snippets Groups Projects
Commit 6a26837d authored by Denis Ledoux's avatar Denis Ledoux
Browse files

[ADD] crm: use company/contact name for fill partner_info in chatter

Sometimes, when you send an email in the chatter, a pop-up is displayed to fill the partner details
This case happens when the email address you send the email is not associated to an existing partner
In such cases, in lead, we use the company name and contact name to fill the partner name
parent 07f355ca
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,7 @@ from openerp import tools
from openerp.addons.base.res.res_partner import format_address
from openerp.osv import fields, osv, orm
from openerp.tools.translate import _
from openerp.tools import email_re
CRM_LEAD_FIELDS_TO_MERGE = ['name',
'partner_id',
......@@ -1032,4 +1033,16 @@ class crm_lead(format_address, osv.osv):
return {'value':{'country_id':country_id}}
return {}
def message_partner_info_from_emails(self, cr, uid, id, emails, link_mail=False, context=None):
res = super(crm_lead, self).message_partner_info_from_emails(cr, uid, id, emails, link_mail=link_mail, context=context)
lead = self.browse(cr, uid, id, context=context)
for partner_info in res:
if not partner_info.get('partner_id') and (lead.partner_name or lead.contact_name):
emails = email_re.findall(partner_info['full_name'] or '')
email = emails and emails[0] or ''
if email and lead.email_from and email.lower() == lead.email_from.lower():
partner_info['full_name'] = '%s <%s>' % (lead.partner_name or lead.contact_name, email)
break
return res
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment