cybrosys
Published in

cybrosys

Communication in a business is very important. Email is the fastest way to transfer information. Main advantages of email communication are:

- Cheap

- Fast

- Easy

- Convenient

- Easy to replicate

In this blog you will learn about:

Odoo gives an option to send email in the modules so that for most of the process, customers can track it even through email. So it is important to give an option to send emails while customizing a module. Here I am going to explain, how can we send an email in a button click also I will be explaining how can we send an email from a wizard.

Let us discuss it with an example:

Create An Email Template To Send The Email In Odoo 13

Here I created a model test. an email with the module name test_email. First, we have to create an email template to send the email:

<odoo><data noupdate="1"><!--Email template --><record id="email_template" model="mail.template"><field name="name">Email Template</field><field name="model_id" ref="test_email.model_test_email"/><field name="email_from">${(object.company_id.email |safe}</field><field name="email_to" >${object.partner_id.email}</field><field name="subject">Ref ${object.name or 'n/a' }</field><field name="auto_delete" eval="True"/><field name="lang">${object.partner_id.lang}</field><field name="body_html"><![CDATA[<p>Hi</p><br/><p>Here is the details of open invoices</p><br/>]]></field></record></data></odoo>

While creating the email template, one has to fill the field email_from. Since we send an email directly from the code, we have to fill the field email_to in the email template itself. Also, we can define the body for the email template as per the requirement.

To know more about email template, please refer the blog Creating Email Templates in Odoo

Add A Button To Send The Email

Next is to add the button to send by email, for that let’s check the XML code to add a button in the form view:

<?xml version="1.0" encoding="utf-8"?><odoo><data><record id="view_test_email_form" model="ir.ui.view"><field name="name">test.email.form</field><field name="model">test.email</field><field name="arch" type="xml"><form><header><button name="action_send_email" string="Send by email" type="object"/></header><sheet><field name="name" readonly="1"/><div><group><field name="partner_id"/></group></div></sheet><div class="oe_chatter"><field name="message_follower_ids" widget="mail_followers"/><field name="activity_ids" widget="mail_activity"/><field name="message_ids" widget="mail_thread"/>
</div>
</form>
</field>
</record>
</data>
</odoo>

Here we added a button with the name “action_send_email” ie “Send by email” in the type object. Next is to define the method in the .py file

Continue Reading…

--

--

--

We are Odoo Gold Partners standing par excellence in Odoo implementation, customization and allied services. We do Source code sale, Custom software development, and Employee outsourcing.

Recommended from Medium

Etermax at Unite Copenhagen 19

A Gentle Introduction to CI/CD Pipeline with Github Actions

Go & TestContainers

Leaving LastPass

Pritunl Release Announcement

Hacking my Building’s Gym Reservation During the Pandemic

Graph Vis: G6 3.4 is released!

Hector wins blockchain hackathon and attributes success to Sabio Coding Bootcamp

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cybrosys Technologies

Cybrosys Technologies

We are Odoo Gold Partners standing par excellence in Odoo implementation, customization and allied services.

More from Medium

AWS scenario-1 : how to Create a Static Website with S3 & Hosting a Static Website on CloudFront

AMAZON ECS BEST PRACTISES

Understanding AWS application development tools

Creating a Simple Website using AWS CloudFormation