Hello, I try to make a modul that send me a normal Email with a Subject and a text.
How can I do this?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Hello, I try to make a modul that send me a normal Email with a Subject and a text.
How can I do this?
try the solution in this link:
https://www.odoo.com/forum/help-1/question/95181/#answer-95185
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
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>
Create an account today to enjoy exclusive features and engage with our awesome community!
РегистрацияRelated Posts | Ответы | Просмотры | Активность | |
---|---|---|---|---|
|
1
авг. 23
|
4749 | ||
|
0
сент. 19
|
4136 | ||
|
2
июн. 19
|
8962 | ||
|
0
авг. 16
|
2867 | ||
|
1
мая 16
|
3583 |