Hilfe

2

how to send email?

how to send email when i click on the button?

Avatar
Verwerfen
2 Antworten
1
Best Answer

Hi aneesh,

     Steps:

1.Create a template for your email ,settings->email->template-> create -> Name-User defined, Applies to- description to model, model- model for creating email, and you can give acces rights, on the content tab you need create the template. In email configuration you need to configure your email address for sender and receiver. And in advanced setting you have an option that you can add a attachment automatically by giving the optional report to print or attach and save the template.

2.You need to create the button with type="object", which the respective method where you have to configure your email.

3.In your model , you need get the template for eg 

        email= self.pool.get('email.template')
        template_id=email.search(cr,uid,[('model_id.model', '=','hello.world')]) 

so using this template you need to compose the email and return        

       ir_model_data = self.pool.get('ir.model.data')
        try:
            compose_form_id = ir_model_data.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')[1]
        except ValueError:
            compose_form_id = False 
        ctx = dict(context)
        ctx.update({
                'default_model': 'hello.world',
                'default_res_id': ids[0],
                'default_use_template': bool(template_id),
                'default_template_id': template_id[0],
                'default_composition_mode': 'comment',
                'mark_so_as_sent': True
            })

       return {
                'type': 'ir.actions.act_window',
                'view_type': 'form',
                'view_mode': 'form',
                'res_model': 'mail.compose.message',
                'views': [(compose_form_id, 'form')],
                'view_id': compose_form_id,
                'target': 'new',
                'context': ctx,
            }

Try this.........

Avatar
Verwerfen