我想给2014年Odoo招聘第一阶段的申请人发邮件。如何使用python实现呢?这是我的代码。
def job_applicant_acknowledgments(self):
for rec in self:
get_first_stage = self.env['hr.recruitment.stage'].search([
'|',
('job_ids', '=', False),
('job_ids', '=', self.id)], order='sequence asc', limit=1)
if self.partner_id and get_first_stage and not emai_sent:
ctx = {}
ctx['email_to'] = rec.partner_id.email
# ctx['email_from'] = self.env.user.user_id.email
# ctx['email_from'] = self.env.user.employee_id.work_email
ctx['send_email'] = True
ctx['partner_id'] = rec.partner_id.id
template = self.env.ref(
'hr_recruitment_custom.job_applicant_acknowledgment')
template.with_context(ctx).send_mail(
rec.id, force_send=True, raise_exception=False)
这就是我需要的。这是python代码,当申请人申请一个职位时,或者如果您创建一个职位id为recruitment,它会向申请人发送电子邮件。
def job_applicant_acknowledgments(self):
for rec in self:
ctx = {}
ctx['email_to'] = rec.partner_id.email
ctx['email_from'] = self.env.user.user_id.email
ctx['send_email'] = True
ctx['partner_id'] = rec.partner_id.id
template = self.env.ref('hr_recruitment_custom.job_applicant_acknowledgment')
template.with_context(ctx).send_mail(
rec.id, force_send=True, raise_exception=False)
我添加的代码:
def job_applicant_acknowledgments_cron(self):
partner_ids = self.env['hr.applicant'].search([('email_sent', '=', False)])
for applicant in partner_ids:
if applicant.email_sent is False:
applicant.job_applicant_acknowledgments()
applicant.email_sent = True