Skip to Content
Menu
This question has been flagged
1 Reply
2867 Views

hi all , iam a newbie to odoo i have this field in my crm module  

    lead_status = fields.Many2one("crm.stage","Lead Status",track_visibility='onchange',default=_get_default_lead_status)


i have created a mail template like this :

<?xml version="1.0" ?>

<odoo>


    <data noupdate="1">

        <record id="crm_lead_mail_template" model="mail.template">

            <field name="name">CRM-OPPORTUNITY_MODIFIED: Send by email</field>

            <field name="model_id" ref="crm_extended.model_crm_lead_extended"/>

            <field name="email_from">guna19may2015@gmail.com</field>

            <field name="email_to">${object.account_manager.email}</field>

            <field name="subject">Opportunity Record Has Been modified</field>

            <field name="body_html" type="html">

                <div style="margin: 0px; padding: 0px;">

                    <p style="margin: 0px; padding: 0px; font-size: 13px;">

                        Dear ${object.account_manager.display_name} 

                        <br /><br />

                        Opportunity ${object.customer_name.display_name}  has been Modified. . 

                        

                        <br /><br />

                        Thank you

                    </p>

                </div>

            </field>

        </record>

    </data>

</odoo>



but my problem here is i want to trigger mail when the lead status changes , can someone give me a hint to do it please

Thank You !

Avatar
Discard
Best Answer

In code call template and send email. Based on requirement override write method, if status change send email.

Example,

    @api.multi
    def write(self, vals):
        if 'lead_status' in vals and self.ids:
            for rec in self:
                template = self.env.ref('module_name.crm_lead_mail_template')
                template.send_mail(rec.id, force_send=True)          
        return super(ClassName, self).write(vals)

Avatar
Discard