我无法在电子邮件中获取自定义数据模板可以任何人帮助我,因为这是我的代码。
class stu_rem(osv.osv):
_inherit = ['mail.thread']
_name = 'student.reminder'
_rec_name = 'stu_id'
_columns = {
'stu_id' : fields.many2one("tender.hearts",'Student Name',required=True),
'stu_name' : fields.char('Name Of the Student',invisible=True),
'stu_father' : fields.char('Father Name',required=True),
'stu_father_email' : fields.char('Email ID',required=True),
'stu_father_num':fields.char('Phone'),
'next_pay_date_rem' : fields.date('Next Payment Date',required=True),
'r_date' : fields.date('Date'),
'r_title' : fields.char('Subject for Email',required=True),
'desc' : fields.text('Description'),
'amt_pay' : fields.float('Pay Amount',required=True),
}
_defaults = {
'r_date' : date.today().strftime('%Y-%m-%d'),
'r_title' : 'Payment Reminder',
}
def action_payment_mail(self, cr, uid, ids, context=None):
'''
This function opens a window to compose an email, with the edi sale template message loaded by default
'''
assert len(ids) == 1, 'This option should only be used for a single id at a time.'
ir_model_data = self.pool.get('ir.model.data')
stu_obj = self.browse(cr,uid,ids)
feed_id = self.pool.get('student.reminder').browse(cr,uid,stu_obj[0])
try:
template_id = ir_model_data.get_object_reference(cr, uid, 'tenderhearts', 'email_template_edi_reminder_payment')[1]
except ValueError:
template_id = False
try:
compose_form_id = ir_model_data.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')[1]
except ValueError:
compose_form_id = False
ctx = dict(context)
# template_id = False
# self.pool.get('sale.order').write(cr,uid,ids,{'state':'sent'},context=None)
ctx.update({
'default_model': 'student.reminder',
'default_res_id': stu_obj[0].id,
'default_use_template': bool(template_id),
'default_template_id': template_id,
'default_composition_mode': 'comment',
'mark_so_as_sent': True
})
return {
'type': 'ir.actions.act_window',
'view_type': 'form',
'view_mode': 'form',
'res_model': 'mail.compose.message',
'views': [(compose_form_id, 'form')],
'view_id': compose_form_id,
'target': 'new',
'context': ctx,
}
这是一个友好的提醒,让您知道您的课程付款 活动是部分到期。如果您已经付款,请丢弃此邮件。 感谢您的不断支持。
<?xml version="1.0" ?>
<record model="ir.actions.act_window" id="action_email_templates_reminder">
<field name="name">Email Templates</field>
<field name="res_model">email.template</field>
<field name="view_type">form</field>
<field name="view_mode">form,tree</field>
<field name="view_id" ref="email_template.email_template_tree" />
<field name="search_view_id" ref="email_template.view_email_template_search"/>
<field name="context">{'search_default_model_id':'student.reminder'}</field>
<field name="context" eval="{'search_default_model_id': ref('Tenderheart.model_student_reminder')}"/>
</record>
</data>
<data noupdate="0">
<record id="email_template_edi_reminder_payment" model="email.template">
<field name="name">${object.r_title}</field>
<field name="email_from">no-reply@tenderhearts.ae</field>
<field name="subject">${object.r_title}</field>
<field name="context" eval="{'search_default_model_id': ref('Tenderheart.model_student_reminder')}"/>
<field name="auto_delete" eval="True"/>
<field name="email_to">${object.stu_father_email}</field>
<field name="body_html">
<![CDATA[<div style="font-family: 'Lucica Grande', Ubuntu, Arial, Verdana, sans-serif; font-size: 12px; color: rgb(34, 34, 34); background-color: #FFF; ">
<h2 align="center"><img src="http://i.imgur.com/zUDvTMJ.jpg" width="100" height="52"/></h2>
<h3>Dear Parents,</h3>
<h4>payment amount ${object.amt_pay}AED due on ${object.next_pay_date_rem} </h4>
<h4>${object.desc}</h4>
<h4>Best Regards.</h4>
<h4>Tender Hearts Arena.</h4>
</div>]]>
</field>
</record>
Here is the snapshot of the data I want to fetch
Here is the snapshot of the mail which is empty
由于
答案 0 :(得分:0)
你可以试试这行代替:
<field name="res_model">mail.template</field>
它可能适合你。