This question has been flagged

Hi people,

Iam trying to send an email to a potential customer when a lead converted to an opportunity. Here is my code.

    def convert_opportunity(self, cr, uid, ids, partner_id, user_ids=False, section_id=False, context=None):
res = super(crm_lead, self).convert_opportunity(cr, uid, ids, partner_id, user_ids, section_id, context=context)
template_id = self.pool.get('ir.model.data').get_object(cr, uid, 'buildafrique_erp', 'opportunity_created')
message_id = self.pool.get('email.template').send_mail(cr, uid, template_id.id, context['active_id'], force_send=True, context=context)
return res

However, the email that is sent is in duplicate, sometimes, four times when I convert one lead to an opportunity. Any Ideas what is causing this? 

Avatar
Discard