Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

2

how to send email?

By
aneesh ATEES Infomedia Pvt Ltd
on 2/11/15, 10:46 PM 708 views

how to send email when i click on the button?

1
Umashankar Subramani
On 2/12/15, 12:32 AM

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.........

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 2/11/15, 10:46 PM
Seen: 708 times
Last updated: 9/16/15, 7:45 AM