77 lines
3.2 KiB
Python
77 lines
3.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
from odoo import api, fields, models, _
|
|
from odoo.exceptions import UserError
|
|
|
|
|
|
class HrJob(models.Model):
|
|
_inherit = "hr.job"
|
|
|
|
prepare_approval_id = fields.Many2one('yuthon.prepare.approval')
|
|
recruitment_approval_id = fields.Many2one('yuthon.recruitment.approval')
|
|
is_pub = fields.Boolean(string="发布状态")
|
|
|
|
def pub_applicant_approval_button(self):
|
|
for pub in self:
|
|
if pub.compiling_status != '1':
|
|
raise UserError('只有缺编的岗位才可以发布申请')
|
|
hr_job_ids = self.env["hr.job"].browse(self._context.get('active_ids', self._context.get('active_id')))
|
|
first_department_id = hr_job_ids[0].department_id
|
|
for hr_job in hr_job_ids:
|
|
hr_job.write({'is_published': True})
|
|
if hr_job.department_id != first_department_id:
|
|
raise UserError("招聘需部门相同,请重新选择")
|
|
enable = bool(hr_job_ids.filtered('is_enable'))
|
|
if not enable:
|
|
raise UserError('岗位失效,请勿提交')
|
|
hr_job_data = [(6, 0, hr_job_ids.ids)]
|
|
form_id = self.env.ref("yuthon_hr_employee_approval.view_yuthon_recruitment_approval_form").id
|
|
return {
|
|
'type': 'ir.actions.act_window',
|
|
'name': '提交招聘需求申请',
|
|
'res_model': 'yuthon.recruitment.approval',
|
|
"views": [[form_id, "form"]],
|
|
"context": {
|
|
'default_recruitment_ids': hr_job_data,
|
|
}
|
|
}
|
|
|
|
def pub_prepare_approval_button(self):
|
|
hr_job_ids = self.env["hr.job"].browse(self._context.get('active_ids', self._context.get('active_id')))
|
|
form_id = self.env.ref("yuthon_hr_employee_approval.view_yuthon_prepare_approval_form").id
|
|
first_department_id = hr_job_ids[0].department_id
|
|
for hr_job in hr_job_ids:
|
|
if hr_job.department_id != first_department_id:
|
|
raise UserError("岗位编制需部门相同,请重新选择")
|
|
hr_job_list = []
|
|
for job in hr_job_ids:
|
|
hr_job_list.append([0, 0, {
|
|
'hr_job_id': job.id,
|
|
'department_id': job.department_id.id,
|
|
'job_type_id': job.job_type_id.id,
|
|
'establishment_quotas': job.establishment_quotas,
|
|
'no_of_employee': job.no_of_employee,
|
|
'compiling_external': job.compiling_external,
|
|
'missing_number': job.missing_number,
|
|
'compiling_status': job.compiling_status,
|
|
'job_personnel': job.job_personnel,
|
|
'remarks': job.remarks,
|
|
}])
|
|
return {
|
|
'type': 'ir.actions.act_window',
|
|
'name': '提交岗位编制调整申请',
|
|
'res_model': 'yuthon.prepare.approval',
|
|
"views": [[form_id, "form"]],
|
|
"context": {
|
|
'default_adjust_information_ids': hr_job_list,
|
|
}
|
|
}
|
|
|
|
def open_job_record(self):
|
|
return {
|
|
"type": "ir.actions.act_window",
|
|
"res_model": 'hr.job',
|
|
"res_id": self.id,
|
|
"name": "任职要求详情",
|
|
"view_mode": "form",
|
|
"target": "new",
|
|
} |