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

I created a method that posts a message on every save to products.product. I post the message with:

self.message_post(cr, uid, pprecord['id'], body='My nice message body', subject='My nice message subject')

But now i would like to use an existing E-Mail Template instead of simple strings to post the message.

Is there already a simple method to directly post an E-Mail Template? 

I played around with: self.pool.get('email.template').render_template(cr, uid, 3, 'product.product', pprecord['id'], context=context) but all i want is to post the E-Mail template and not to read all the fields one by one...

 

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

Already answerd in an other Question. https://www.odoo.com/forum/help-1/question/how-to-send-invoice-mail-automatically-24620

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

Make appropriate email template via Settings > Configuration > Email > Templates. Name it like 'my_template'.

email_pool = self.pool.get('email.template)

ids = email_pool.search(cr, uid, [{'name', '=', 'my_template'}])

body = email_pool.render_template(cr, uid, ids[0], 'product.product', pprecord['id'], context=context)

self.message_post(cr, uid, pprecord['id'], body=body, subject='My nice message subject')

 

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 10 23
4110
3
thg 7 18
6333
1
thg 11 17
8480
0
thg 6 25
521
1
thg 5 25
1243