How to send email notification when Project Issue was created? Odoo 9

Viewed 1353

Hi I have created new issue but I cannot get email notification.

How do you do that?

Edited

I've add some code below but I cannot get message_follower_ids from self to send emails.

class project_issue(osv.osv):
_inherit = 'project.issue'
_columns = {}

def create(self, cr, uid, vals, context=None):
    res = super(project_issue, self).create(cr, uid, vals, context=context)
    return res

Updated

I updated the code to get followers email address and successfully sent the mails but they go to one email.

And Its object.name is partner's name but I want it to be issue name.

def create(self, cr, uid, vals, context=None):
    res = super(project_issue, self).create(cr, uid, vals, context=context)
    issue = self.pool.get('project.issue').browse(cr, uid, res, context=context)

    template = self.pool.get('ir.model.data').get_object(cr, uid, 'customized_project', 'email_template_customer_auto')

    for follower in issue.message_partner_ids:
        self.pool.get('mail.template').send_mail(cr, uid, template.id, follower.id, force_send=True, raise_exception=True, context=context)

here is a email template

<?xml version="1.0" encoding="utf-8"?>
<openerp>
  <data noupdate="1">
      <!--Email template-->
      <record id="email_template_customer_auto" model="mail.template">
          <field name="name">Send email notification for issue creation</field>
          <field name="email_from">${object.company_id and object.company_id.email or ''}</field>
          <field name="subject">New Issue created ${object.name}</field>
          <field name="email_to">${object.email|safe}</field>
          <field name="model_id" ref="model_project_issue"/>
          <field name="auto_delete" eval="True"/>
          <field name="lang">${object.lang}</field>
          <field name="body_html"><![CDATA[
            """
            Write here a body of email using HTML tag.....
            """
            ]]>
          </field>
      </record>
   </data>
</openerp>
1 Answers
Related