From f3433d30aaf59dbf8f73f6a187646570f3554eb0 Mon Sep 17 00:00:00 2001 From: odoo Date: Wed, 30 Mar 2011 13:43:24 +0200 Subject: [PATCH] [FIX] do not send email if email_to is false, do not link with contact if no partner bzr revid: odoo@ns307129.ovh.net-20110330114324-4ry4pixddj8jppd7 --- addons/crm/wizard/crm_lead_to_opportunity.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/crm/wizard/crm_lead_to_opportunity.py b/addons/crm/wizard/crm_lead_to_opportunity.py index 3aee5afd00e..44c83f7c70c 100644 --- a/addons/crm/wizard/crm_lead_to_opportunity.py +++ b/addons/crm/wizard/crm_lead_to_opportunity.py @@ -114,8 +114,10 @@ Leads Could not convert into Opportunity")) 'stage_id': stage_ids and stage_ids[0] or False, 'date_action': time.strftime('%Y-%m-%d %H:%M:%S'), } - if address_id: + if partner_id and address_id: vals['partner_address_id'] = address_id[0] + else: + vals['partner_address_id'] = False lead.write(vals, context=context) leads.history(cr, uid, [lead], _('Converted to opportunity'), details='Converted to Opportunity', context=context) @@ -128,6 +130,8 @@ Leads Could not convert into Opportunity")) def send_mail_to_salesman(self, lead): email_to = lead.user_id and lead.user_id.user_email + if not email_to: + return email_from = lead.section_id and lead.section_id.user_id and lead.section_id.user_id.user_email or email_to partner = lead.partner_id and lead.partner_id.name or lead.partner_name subject = "lead %s converted into opportunity" % lead.name @@ -188,7 +192,6 @@ Leads Could not convert into Opportunity")) else: partner_id = False - self._convert(cr, uid, ids, lead, partner_id, stage_ids, context=context) self.send_mail_to_salesman(lead) #If we convert in mass, don't merge if there is no other opportunity but no warning