[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
This commit is contained in:
odoo 2011-03-30 13:43:24 +02:00
parent 3b24b3ce06
commit f3433d30aa
1 changed files with 5 additions and 2 deletions

View File

@ -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