콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
4 답글
7759 화면

__init__.py

import template_task

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

__openerp__.py

{

'name': 'ProjectTask',

'version': '1.1',

'depends': ['project'],

'data': ['task_email_template_data.xml'],

'installable': True,

'auto_install': False,

'application': True,

}

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

template_task.py

from openerp import api,fields,models

class task(models.Model):

_inherit = 'project.task'

@api.model

def create(self,vals):

 

res=super(task,self).create(vals)


self.task_send_mail()


return res

@api.multi

def task_send_mail(self):


mail_ids = []

mail_pool = self.env['mail.mail']


template_id = self.env['ir.model.data'].get_object_reference('task_templatess','task_email_template')[1]


email_obj = self.env['mail.template'].browse(template_id)


mail_id = email_obj.send_mail(template_id)

 

mail_ids.append(mail_id)

 

if mail_ids:

res = mail_pool.send(self,mail_ids)

 

return res 

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

task_email_template_data.xml

<?xml version="1.0" encoding="utf-8"?>

<odoo>

<data noupdate="0">

<!--email template-->

<record id="task_email_template" model="mail.template">

<field name="name">Send Email project template</field>

<field name="email_from">pketul94@gmail.com</field>

<field name="subject">New Customer created ${object.name}</field>

<field name="email_to">${object.user_id.email}</field>

<field name="model_id" ref="task_templatess.model_project_task"/>

<field name="auto_delete" eval="True"/>

<field name="body_html"><![CDATA[

<p> HELLLLLLLLLLLLLLLLLO </p>

]]></field>

</record>

</data>

</odoo>


when i create a task its create and send mail but error is the "mail delivery fail" how to fix it 

아바타
취소

why you doing extra coding. Task created Email Facility available only we have to configure that.

베스트 답변

You can use an Automated Action with the following code:


template_email = env["mail.template"].search([('name','=','Task Created')]).id
env["mail.template"].browse(template_email).send_mail(record.id, force_send=True)
아바타
취소
베스트 답변

ketul, 

Create automated action and Server action for Task.

When New Task is Generated then it will automatically send Email.

You can set Email Template,Trigger Time any Many More.

아바타
취소
작성자 베스트 답변

Hello sir,

sir I provide my own template through mail and when i send mail system not take user mail address which i give. system take "demo.portal@yourcompny.example.com" and i don't know how to fetch the user email address 

아바타
취소
관련 게시물 답글 화면 활동
0
1월 25
3
0
10월 24
1478
1
2월 24
5692
0
11월 23
1298
1
6월 25
23701