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.

1

How to make a modul with normal email function

By
wizardz
on 1/26/16, 4:53 AM 543 views

Hello, I try to make a modul that send me a normal Email with a Subject and a text.

How can I do this?

1

Tarek Mohamed Ibrahim

--Tarek Mohamed Ibrahim--
896
| 5 3 7
Gîza, Egypt
--Tarek Mohamed Ibrahim--

I am an old VFP developer on ERP

I have moved to 2p since Nov-2014 and started developing with Python on Odoo.

https://www.linkedin.com/profile/public-profile-settings?trk=prof-edit-edit-public_profile

tibrahim@2p.com.sa

Tarek Mohamed Ibrahim
On 1/26/16, 9:59 AM

try the solution in this link:

https://www.odoo.com/forum/help-1/question/95181/#answer-95185

0
wizardz
On 1/27/16, 2:49 AM

The only thing I want is a BUTTON, that when I'm clicking this Button, a Textfield can be send with text to an email.



Check example above

Dr Obx
on 1/27/16, 4:28 AM
0
Dr Obx
On 1/26/16, 10:10 AM

This should go where you want to call it:

self.single(cr, uid, ids, context=context)

example (in my case method is called when if statement is as follows):

if cust > (2.5 * mwos):

self.single(cr, uid, ids, context=context)

method:

def single(self, cr, uid, ids, context=None):

vals = {}

domain=[('name','like','Your_template_name')]

templates = self.pool.get('email.template').search(cr,uid,domain)

if not templates:

return

template = self.pool.get('email.template').browse(cr,uid,templates[0])

if template.email_to:

self.pool.get('email.template').send_mail(cr, uid, template.id, ids[0], True, context=context)


Template: (you can add it into your view.xml or as a separate file template.xml but then you have to add it into the section 'data' inside the __openerp__.py including path ex. /static/src/xml//template.xml)

<?xml version="1.0" encoding="utf-8"?>

<openerp>

<data noupdate="1">

<record id="stock_check_m" model="email.template">

<field name="name">Your_template_name</field>

<field name="email_from">your@address.com</field>

<field name="subject">Order</field>

<field name="model_id" ref="module_name.method_name"/>

<field name="email_to" >roberta@uznam.net.pl</field>

<field name="partner_to"></field>

<field name="auto_delete" eval="False"/>

<field name="body_html">

<![CDATA[

<style>

/* some style defs */

</style>

<field name="email_body"/>

<div style="padding: 10px; width:100%; font-size: 40px; height: 80px;top: 0px; color:#FFFFFF; background-color: #2EA2D2; margin-left: auto;margin-right: auto;">

<h1>Header</h1></div>

<div style="height: auto;margin-left:12px;margin-top:30px;">

<p class="red">Some text</p>

${object.emailbody}<!-- Here you can add some more variables. Can be done while you setting up template in Odoo -->

<p>U R G E N T !</p>

</div>

]]>

</field>

</record>

 </data>

</openerp>

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: 1/26/16, 4:53 AM
Seen: 543 times
Last updated: 1/27/16, 2:49 AM