Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
4548 Lượt xem

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

How can I do this?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

try the solution in this link:

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

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

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.



Ảnh đại diện
Huỷ bỏ

Check example above

Câu trả lời hay nhất

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>

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 8 23
4749
0
thg 9 19
4136
2
thg 6 19
8962
0
thg 8 16
2867
1
thg 5 16
3583