From 6a26837d245be9aab12e603e12a9388cf9e204ab Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Thu, 31 Jul 2014 15:33:41 +0200 Subject: [PATCH] [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 --- addons/crm/crm_lead.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index b82f5a4..c4fd782 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -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: -- 1.7.10.4