Files
gzth/yuthon_hr_employee_approval/models/yuthon_message_login.py
T
2025-07-25 11:49:16 +08:00

223 lines
12 KiB
Python

from odoo import models, fields, api
from odoo.exceptions import UserError
nation_list = [('a', '汉族'), ('b', '壮族'), ('v', '满族'), ('d', '回族'), ('e', '苗族'), ('f', '维吾尔族'),
('g', '土家族'), ('h', '彝族'), ('i', '蒙古族'), ('j', '藏族'), ('k', '布依族'), ('l', '侗族'),
('m', '瑶族'), ('n', '朝鲜族'), ('o', '白族'), ('p', '哈尼族'), ('q', '哈萨克族'), ('r', '黎族'),
('s', '傣族'), ('t', '畲族'), ('u', '傈僳族'), ('v3', '仡佬族'), ('w', '东乡族'), ('x', '拉祜族'),
('y', '水族'), ('z', '佤族'), ('a1', '纳西族'), ('b1', '羌族'), ('c1', '仫佬族'), ('d1', '锡伯族'),
('e1', '柯尔克孜族'), ('f1', '达斡尔族'), ('g1', '景颇族'), ('h1', '毛南族'), ('i1', '撒拉族'),
('j1', '布朗族'), ('k1', '塔吉克族'), ('l1', '阿昌族'), ('m1', '普米族'), ('n1', '鄂温克族'),
('o1', '怒族'),
('p1', '京族'), ('q1', '基诺族'), ('r1', '德昂族'), ('s1', '保安族'), ('t1', '俄罗斯族'),
('u1', '裕固族'),
('v1', '乌孜别克族'), ('w1', '门巴族'), ('x1', '鄂伦春族'), ('y1', '独龙族'), ('z1', '塔塔尔族'),
('a2', '赫哲族'),
('b2', '高山族'), ('c2', '珞巴族'), ('d2', '壮族')]
class YuthonMessageLogin(models.Model):
_name = 'yuthon.message.login'
_description = "个人信息登记表"
_rec_name = 'name'
_inherit = ['soong.workflow.mixin', 'mail.thread.main.attachment', 'mail.activity.mixin']
# 基本信息
name = fields.Char(string='标题', default="人员信息登记表")
code = fields.Char(string="编号",
default=lambda self: self.env['ir.sequence'].next_by_code('yuthon_message_login_code'))
users_id = fields.Many2one('res.users', string="申请人", default=lambda self: self.env.user.id)
department_id = fields.Many2one('hr.department', string='部门')
staff_name = fields.Char(string='姓名')
sex = fields.Selection([('male', '男'), ('female', '女')], string='性别')
date_birth = fields.Date(string='出生年月')
nation = fields.Char(string='民族')
origin = fields.Char(string='籍贯')
political = fields.Selection([('cpc_dang', '中共党员'), ('nld', '民盟'),
('league_member', '共青团员'), ('people', '群众')], string="政治面貌")
party_time = fields.Date(string='入党时间')
house_hold = fields.Char(string='户口所在地')
house_type = fields.Selection([('city', '城市'), ('rural', '农村')], string='户口类型')
marital_status = fields.Selection([('married', '已婚'), ('unmarried', '未婚')], string='婚姻状况')
working_time = fields.Date(string='参加工作时间')
current_address = fields.Char(string='现居住地址')
phone = fields.Char(string='手机')
id_card = fields.Char(string='身份证号')
residential_phone = fields.Char(string='住宅电话')
email = fields.Char(string='电子邮箱')
home_address = fields.Char(string='家庭住址')
home_phone = fields.Char(string='家庭电话')
hobbies = fields.Char(string='兴趣爱好')
specialty = fields.Char(string='特长')
self_evaluation = fields.Text(string='自我评价')
work_end = fields.Boolean(string="结束")
# 配偶情况(已婚者)
spouse_name = fields.Char(string='姓名')
spouse_date = fields.Date(string='出生年月')
spouse_phone = fields.Char(string='联系电话')
spouse_work = fields.Char(string='工作单位')
spouse_position = fields.Char(string='职务')
spouse_degree = fields.Char(string='学历') #
# 最近工作情况
last_work = fields.Char(string='单位名称')
last_work_department = fields.Many2one('hr.department', string="部门")
last_work_position = fields.Many2one('hr.job', string="岗位")
last_work_grades = fields.Char(string='工作内容成绩')
last_work_training = fields.Char(string='接受的培训')
last_work_reason = fields.Char(string='离职原因')
# 亲属情况
is_relatives_work = fields.Boolean(string='本单位是否有亲属')
# 附件
image_1920 = fields.Image("一寸照")
id_card_id = fields.Many2one('ir.attachment', string='身份证')
expirationDate = fields.Date(string='身份证有效期')
residence_permit = fields.Char(string='居住证(非本市提供的办理证明,截图也可)')
is_expertise = fields.Boolean(string='专业证书/职称')
social_security_id = fields.Many2one('ir.attachment', string='社保清单')
social_validity = fields.Date(string='截至到入职前')
is_bank_card = fields.Boolean(string='银行卡储蓄卡')
bank_name = fields.Char(string='开户行')
bank_phone = fields.Char(string='卡号')
is_driving_license = fields.Boolean(string='驾驶证')
driving_license_id = fields.Many2one('ir.attachment', string='驾驶证')
driving_license_validity = fields.Date(string='有效期')
resignation_id = fields.Many2one('ir.attachment', string='离职证明')
medical_exam_cost = fields.Float(string='体检费用(含乙肝)')
is_issues = fields.Boolean(string='是否上会')
issues_result = fields.Html(string="会议结果")
related_issues_id = fields.Many2one('issue.library', string="关联议题")
login_document_id = fields.Many2one('ir.attachment', string="简历附件")
urgency_level = fields.Selection([('normal', '普件'), ('urgent', '急件'), ('emergency', '特急件')], string='紧急度',
default='normal')
active = fields.Boolean('Active', default=True, tracking=True)
def _get_default_name_title(self):
return self._description if self._description else self._name
name_title = fields.Char(default=_get_default_name_title)
# 紧急联系人
emergency_contact_ids = fields.One2many('hr.yuthon.emergency.contact.line', 'message_login_id',
string="紧急联系人明细行")
# 教育经历
education_experience_ids = fields.One2many('hr.yuthon.education.experience.line', 'message_login_id',
string="教育经历明细行")
# 工作经历
work_experience_ids = fields.One2many('hr.yuthon.work.experience.line', 'message_login_id', string="工作经历明细行")
# 直属亲属情况
direct_relative_ids = fields.One2many('hr.yuthon.directly.detail.lines', 'message_login_id',
string="直属亲属情况明细行")
# 个人技能
personal_skill_ids = fields.One2many('hr.yuthon.personal.skills.schedule', 'message_login_id',
string="个人技能明细行")
# 最近工作单位
last_work_unit_ids = fields.One2many('hr.yuthon.recent.work.detail.line', 'message_login_id',
string="最近工作单位情况")
# 获奖情况
awards_line_ids = fields.One2many('awards.line', 'message_login_id', string="获奖情况明细行")
# 亲属在本单位
kindred_line_ids = fields.One2many('kindred.line', 'message_login_id', string="最近工作单位情况")
# 附件
attachment_ids = fields.One2many('education.details.line', 'diploma_id', string="学历证(全日制)")
part_time_ids = fields.One2many('education.details.line1', 'diploma_id', string="学历证(非全日制)")
degree_id_ids = fields.One2many('education.details.line2', 'degree_id', string="学位证")
certificate_ids = fields.One2many('certificates.detail.line', 'certificate_id', string="专业证书")
users_ids = fields.Many2many('res.users', string="当前经办人", store=True, compute='_compute_users_ids')
@api.depends('code')
def _compute_users_ids(self):
for record in self:
if not record.code:
record.users_ids = False
continue
workflow_records = self.env['soong.workflow.record'].search([
('code', '=', record.code),
], limit=1)
if workflow_records:
employee_ids = workflow_records.employee_ids
user_ids = employee_ids.mapped('user_id').ids
record.users_ids = [(6, 0, user_ids)]
else:
record.users_ids = False
@api.onchange('is_issues')
def _onchange_is_issues(self):
if self.is_issues:
issue_id = self.env['issue.library'].create({'name': self.name})
self.related_issues_id = issue_id.id
workflow_record_id = self.env["soong.workflow.record"].search(
[("res_model", "=", self._name), ("res_id", "=", self.id)])
self.env['issue.library.approval.line'].create({
'issue_library_id': issue_id.id,
'workflow_record_id': workflow_record_id.id,
'approval_type': workflow_record_id.workflow_id.id,
'code': self.code,
'approval_date': fields.Datetime.now(),
})
def pub_name_button(self):
code_url = self.get_base_url() + "/hr/employee/create?employee_id=" + str(self.id)
action = {
'type': 'ir.actions.act_window',
'name': "访问地址",
'res_model': 'yuthon.website.employee.wizard',
'views': [(False, 'form')],
'target': 'new',
'context': {
'default_employee_url': code_url,
}
}
return action
class EducationalDetailsLine(models.Model):
_name = 'education.details.line'
_description = '学历证(全日制)'
diploma_id = fields.Many2one('yuthon.message.login', string="关联个人信息")
graduation_id = fields.Many2one('ir.attachment', string="毕业证书")
validation_reports = fields.Char(string="验证报告")
class EducationalDetailsLine1(models.Model):
_name = 'education.details.line1'
_description = '学历证(非全日制)'
diploma_id = fields.Many2one('yuthon.message.login', string="关联个人信息")
graduation_id = fields.Many2one('ir.attachment', string="毕业证书")
validation_reports = fields.Char(string="验证报告")
class EducationalDetailsLine2(models.Model):
_name = 'education.details.line2'
_description = '学位证'
degree_id = fields.Many2one('yuthon.message.login', string="关联个人信息")
graduation_id = fields.Many2one('ir.attachment', string="学位证")
class CertificateDetailLine(models.Model):
_name = 'certificates.detail.line'
_description = '专业证书'
certificate_id = fields.Many2one('yuthon.message.login', string="关联个人信息")
professional_certificates_id = fields.Many2one('ir.attachment', string="专业证书/职称")
professional_certificate_validity = fields.Date(string="有效期")
class KindredLine(models.Model):
_name = 'kindred.line'
_description = '是否有亲属在本单位'
message_login_id = fields.Many2one('yuthon.message.login', string="关联个人信息")
relatives_work = fields.Char(string='亲属姓名')
relatives_work_date = fields.Date(string='出生年月')
relatives_work_phone = fields.Char(string='联系电话')
relatives_work_address = fields.Char(string='家庭住址')
relatives_work_department = fields.Many2one('hr.department', string='部门')
relatives_work_position = fields.Selection([("parents", "父母"), ("children", "子女"),
("spouse", "配偶"), ("spouse", "其他")], string="关系")