Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3 Risposte
4557 Visualizzazioni

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
Abbandona
Risposta migliore

try the solution in this link:

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

Avatar
Abbandona
Autore Risposta migliore

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
Abbandona

Check example above

Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
1
ago 23
4751
0
set 19
4137
2
giu 19
8962
0
ago 16
2870
1
mag 16
3585