Skip to Content
Menu
This question has been flagged
2 Replies
1304 Views

hi all i have model called crm.lead.extended, i want to trigger mail notification when a record is created in that , how to do that?  i want this to be done by code 

i have created some sample functions for that someone check and confirm this because iam not getting any mails when i create a record

    @ api.model

    def create (self, vals):

        rec = super (crm_extended, self) .create (vals)

        if 'opportunity_id' in vals:

            template = self.env.ref ('crm_extended.create_crm_lead_mail_template')

            for rec in self:

                template.send_mail (rec.id, force_send = True) 

        return rec


    @ api.model

    def create (self, vals):

        vals ['usage'] = 'crm.lead.extended'

        crm.lead.extended = super (crm_extended, self) .create (vals)

        self._update_cron ()

        self._update_registry ()

        return crm.lead.extended

Avatar
Discard

Send email on some event: https://goo.gl/z16PBZ

Best Answer

Hi,

Just add some print statements inside the code and see what is returned by the template.send_mail (rec.id, force_send = True) and also ensure that the template with the given reference exists.

To ensure that the mail is generated or not, am not sure how you confirmed it, activate the debug mode and navigate to Settings -> Technical -> Emails -> Emails, check and see whether email is getting created here.


Thanks

Avatar
Discard