Se rendre au contenu
Menu
Cette question a été signalée
3 Réponses
4549 Vues

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

How can I do this?

Avatar
Ignorer
Meilleure réponse

try the solution in this link:

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

Avatar
Ignorer
Auteur Meilleure réponse

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.



Avatar
Ignorer

Check example above

Meilleure réponse

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>

Avatar
Ignorer
Publications associées Réponses Vues Activité
1
août 23
4749
0
sept. 19
4136
2
juin 19
8962
0
août 16
2867
1
mai 16
3583