ZestyBeanz Technologies Pvt Ltd 4th Floor, Nila, Technopark Thiruvananthapuram,
India – 695581
Phone: +91 471 4063254
Fax : +91 471 2700171


ZestyBeanz Technologies Pvt Ltd
2987, Manikkath Cross Road
Ravipuram, Kochi, India - 682016
Phone: +91 484 4063254


Zesty Labs
Office # 2003, Millennium Plaza Building
Sheikh Zayed Rd, Dubai, UAE
Phone: +971 4333 2222​
Mobile: +971-56-2708993​


ZestyBeanz Technologies GmbH
Reuterstraße 1
90408 Nürnberg
Fon: +49 911 4801 444
Fax: +49 911 4801 445

Email using email_template in OpenERP 6.1

Contact Form

Prajul P T's picture

Email using email_template in OpenERP 6.1

email_template is a default module of OpenERP which is used to send emails from OpenERP. It is much easier than smtp_client and the template of the mail can be easily customized. We can configure outgoing email server and template of email_template from Setting > Configuration > Email. The outgoing mail server of email_template can be configured from "Outgoing Mail Servers" in  Setting > Configuration > Email. The following is a screenshot of configuring outgoing mail server in email_template.

In outgoing mail server menu, there are some mandatory fields which has to be configured by the user. These parameters are used to configure the mail server. 

  • The SMTP Server : IP or Host name of SMTP server
  • SMTP Port : SMTP Port
  • Debugging : If enabled, full output of the SMTP session will be written to server log at debug level
  • Connection Security : Connection security schema
  • Username : Username of the email
  • Password : Password of the email

Another important feature of email_template is the Template which can be found in Setting > Configuration > Email > Template. This is used to specify the format in which the email has to be send. A screenshot of the Template in email_template is shown below:

In template, we can set 

  • Name : Name of the template
  • Related document model : Model to which the template is related

In Email Detail Tab, we can set:

  • From : Sender address
  • To : Destination mail address
  • CC : CC Address if required
  • BCC : BCC Address if required
  • Reply To : Preferred Reply address
  • Subject : Subject of the mail
  • Body : Body of the email

Body of the email can be either plain text or an HTML format. In plain text the body can be created using the plain text format and in HTML we can create the mail body in HTML. We also have the freedom to select the language in which the mail is to be send. This is specified in Language selection field in Email Detail Tab.

Another main feature of email_template is the freedom to dynamically specify the field values like From, To, etc. The mail template can be customized any time without modifying the code. Even a person without technical expertise in OpenERP coding can  set the fields using Dynamic Value Builder.

Dynamic Value Builder consist of following fields:

  • Field : Select field from Related Document Model
  • Sub-Model : When a relation field like many2one is selected, this field specify the Related model the relation goes to.
  • Sub-field : When a relation field is selected, this field let us select the target field inside the Sub-Model
  • Null Value : Optional value to use when the target field is empty or Null
  • Expression : This is the resulting expression generated when the fields are selected in Dynamic Value Builder. This can be copy pasted in fields in email template.

In Advanced tab, We can select

  • Outgoing Mail Server : Outgoing Mail Server configured before
  • Resource Tracking : Enables us to track the mail and to map the replies to the corresponding resource record
  • Auto Delete : Permanently delete the email after sending it to save space

In this tab, we have an option to attach files to email. We can see an button Add Sidebar Button. This creates a button in sidebar in the related document model form view which helps in sending email any time from the form view. For example I have created a template for the sale.order and a sidebar button is created by clicking "Add Sidebar Button" button in template, a new button will be created as shown below:

When this button is clicked, a window pops up using which we can send email as shown below:

There can be situation in which client want to send email when a particular button is clicked. For example if a client want to send a mail to the hr manager when a leave application by an employee has been confirmed. For this create a template for hr_holidays model, inherit the button action to confirm the leave from which the mail has to be send, Search and find the id of the template using which the mail has to be send, call the function send_mail in email_template and pass the arguments like template id, resource id to it. Mail will be send every time the button is clicked. 


Anonymous's picture

Hello, Followed above steps

Followed above steps for my module latest_base. However system displays following error

AttributeError: 'latest_base' object has no attribute 'message_post'

Any idea to fix this issue.. Thanks

Anonymous's picture

Hi Prajul, First of all, very

Hi Prajul,

First of all, very good post.

I experiencing some issues with sending a mail using the sidebar button created from the template and with the files attached.

I created a template for sales.order. What I want to do is have a button on the side bar to send a mail to the partner with the sales quotation before I confirm the order. To send the quotation I want either attach the pdf or create a table within the body of the message with the html table with the order lines. I couldn't achieve any case.

To set up the template I create the structure of the body in both, plain and html text. At the tab 'Advanced' in the field 'Optional report to print and attach' I select 'Quotation / Order', and I added the sidebar button.

When I send a mail by clicking on the sidebar button from the Sale order form, the pop-up shows up and I send the mail. But if I go to Settings->Configuration->Email->Messages the mail I am gonna send is there. But taking a look inside the body is plain (according to 'Message type' in tab 'Advanced' and what I see) and there is not any document attached. All this is verified when I send and I get the mail.

I have several questions:

To attach the quotation pdf, it has to be already created and attached to the order?
Where can I define the type of the mail to html?

Thank you in advance

Bouilleaux Kevin's picture

It's difficult to find

It's difficult to find educated people in this particular topic, but you seem like you know what you're
talking about! Thanks

positionnement google's picture

Hello i'm Lashawn , i'm on

Hello i'm Lashawn , i'm on your page for the first time and i was searching about this topic , zesty beanz ,since 2 or 3 hours! Many thanks you make my day!! Keep Writing, it's so informative and cool news on Reply to comment | Zesty Beanz.

Prajul P T's picture

Thank you sir, thank you very

Thank you sir, thank you very much......

Marie's picture

Hello, First of all thanks


First of all thanks for your post!!!

I have an issue with a template for meeting as I would like to send the mail to all attendees and not just to the partner contact.

the object I take is ${object.attendee_ids}
and the result is [browse_record(calendar.attendee, 148), browse_record(calendar.attendee, 149)]

I need to get the emails of the attendee but don't know how to do this as it's a many2many field.

Could you help me with this?

I'm using openerp 6.1

Many Thanks

get more views's picture

Hello, I enjoy reading

Hello, I enjoy reading through your article. I like to write a little comment to support you.

Prajul P T's picture

You are always welcome...

You are always welcome...

Prajul P T's picture

Hi Marie, Please try  <%

Hi Marie,

Please try 

<% y = [ for z in object.attendee_ids] %>${','.join(y)} 

where email is the field for email in the related model of attendee_ids.

Marie's picture

Dear Prajul, I started to

Dear Prajul,

I started to implement Openerp v7 and the code I used <?php y = [ for z in object.attendee_ids?>${','.join(y)} is not longer working.

I get errors like openerp.addons.email_template.email_template: failed to render mako template value u"<?php y = [ for z in object.partner_ids?>${','.join(y)}"

Traceback (most recent call last):
File "/opt/openerp/server/openerp/addons/email_template/", line 99, in render_template
result = mako_template_env.from_string(template).render(variables)
File "/usr/lib64/python2.6/site-packages/jinja2/", line 669, in render
return self.environment.handle_exception(exc_info, True)
File "", line 1, in top-level template code
File "/usr/lib64/python2.6/site-packages/jinja2/", line 225, in getattr
value = getattr(obj, attribute)
UndefinedError: 'browse_record' object has no attribute 'partner_id'
Traceback (most recent call last):
File "/opt/openerp/server/openerp/addons/email_template/", line 99, in render_template
result = mako_template_env.from_string(template).render(variables)
File "/usr/lib64/python2.6/site-packages/jinja2/", line 563, in from_string
return cls.from_code(self, self.compile(source), globals, None)
File "/usr/lib64/python2.6/site-packages/jinja2/", line 448, in compile
self.handle_exception(exc_info, source_hint=source)
File "", line 1, in template
TemplateSyntaxError: unknown tag 'y'

I think to understand that the issue is the variable but can't find out how to solve it

Best regards