!142 employee字段更新

Merge pull request !142 from dev_hong
This commit is contained in:
李鹏宇
2024-08-19 06:19:54 +00:00
committed by Gitee
3 changed files with 58 additions and 60 deletions
@@ -36,6 +36,8 @@ class YuthonEducationExperienceLine(models.Model):
start_date = fields.Date(string="入学时间")
end_date = fields.Date(string="毕业时间")
professional = fields.Char(string="专业")
Part_time_degree = fields.Char(string="非全日制学历学位")
full_time_degree = fields.Char(string="全日制学历学位")
major_courses = fields.Char(string="主修课程")
+50 -40
View File
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from odoo import api, fields, models
from datetime import datetime
nation_list = [('a', '汉族'), ('b', '壮族'), ('v', '满族'), ('d', '回族'), ('e', '苗族'), ('f', '维吾尔族'),
('g', '土家族'), ('h', '彝族'), ('i', '蒙古族'), ('j', '藏族'), ('k', '布依族'), ('l', '侗族'),
@@ -22,25 +23,26 @@ class YuthonHrEmployee(models.Model):
# odoo里是这样做的,一个用户可以多个公司绑定多个员工,每个员工都有自己的部门和岗位
number = fields.Char(string="编号")
use_user_type = fields.Selection([('formal', '正式工'), ('labor', '劳务派遣'),
('part_time', '兼职人员'), ('practice', '正式工')], string="用工形式")
use_user_type = fields.Selection([('formal', '正式职工'), ('labor', '劳务协议'),
('part_time', '兼职协议'), ('employment', '兼职用工')], string="用工形式")
user_number = fields.Char(string="员工编号")
job_lv_id = fields.Many2one('yuthon.job.lv', string="最新职级")
# 个人信息
user_salary = fields.Float(string="基本工资")
job_lv_salary = fields.Float(string="职级工资")
entry_time = fields.Datetime(string="入职时间")
confirmation_time = fields.Datetime(string="转正时间")
company_old = fields.Integer(string="司龄")
entry_date = fields.Date(string="入职时间")
confirmation_date = fields.Date(string="转正时间")
company_old = fields.Integer(string="司龄", compute='_compute_company_old')
user_sex = fields.Selection([('girl', '女'), ('boy', '男')], string="性别")
user_number_start_time = fields.Date(string="身份中有效开始时间")
user_number_end_time = fields.Date(string="身份证有效到期时间")
nation = fields.Selection(nation_list, string="民族")
old = fields.Integer(string="年龄")
old = fields.Integer(string="年龄", compute='_compute_birthday_old')
birthday_month = fields.Integer(string="生日月份", compute='_compute_birthday_old')
user_type = fields.Char(string="人员类别")
retire_data = fields.Date(string="退休日期")
retire_years = fields.Integer(string="离退休年限")
political_aspects = fields.Selection([('dang', '党员'), ('people', '群众')], string="政治面貌")
retire_date = fields.Date(string="退休日期")
retire_years = fields.Integer(string="离退休年限", compute='_compute_retire_years')
political_aspects = fields.Selection([('cpc_dang', '中共党员'), ('nld', '民盟'), ('league_member', '共青团员'), ('people', '群众')], string="政治面貌")
dang_data = fields.Date(string="入团(党)时间")
user_origin = fields.Char(string="籍贯")
user_location = fields.Char(string="户口所在地")
@@ -57,7 +59,6 @@ class YuthonHrEmployee(models.Model):
cumulative_work_month = fields.Integer(string="累计工作月数")
cumulative_work_years = fields.Integer(string="累计工作年限")
# 教育
full_degree = fields.Selection([('full', '全日制学历学位'), ('no_full', '非全日制学历学位')], string="学历学位")
high_degree = fields.Char(string="最高学历")
high_degree2 = fields.Char(string="最高学位")
graduate_school = fields.Char(string="毕业院校")
@@ -116,35 +117,44 @@ class YuthonHrEmployee(models.Model):
else:
social.social_insurance_time = False
@api.depends('entry_date')
def _compute_company_old(self):
"""司龄计算"""
for record in self:
if record.entry_date:
today = datetime.now().date()
years_diff = today.year - record.entry_date.year
months_diff = today.month - record.entry_date.month
if today.month < record.entry_date.month:
years_diff -= 1
months_diff += 12
record.company_old = years_diff * 12 + months_diff
else:
record.company_old = 0
@api.depends('birthday')
def _compute_birthday_old(self):
"""生日月份 年龄 计算"""
for record in self:
if record.birthday:
today = datetime.now().date()
record.birthday_month = record.birthday.month
record.old = today.year - record.birthday.year
else:
record.birthday_month = 0
record.old = 0
@api.depends('retire_date')
def _compute_retire_years(self):
"""离退休年限计算"""
for record in self:
if record.retire_date:
today = datetime.now().date()
years_diff = today.year - record.retire_date.year
compute = years_diff
if compute < 0:
record.retire_years = -1 * compute
else:
record.retire_years = 0
else:
record.retire_years = 0
@@ -49,8 +49,8 @@
<field name="job_lv_salary"/>
<field name="bank_account_id" context="{'default_partner_id': work_contact_id}"
options="{'no_quick_create': True}" readonly="not id"/>
<field name="entry_time"/>
<field name="confirmation_time"/>
<field name="entry_date"/>
<field name="confirmation_date"/>
<field name="company_old"/>
</group>
<group string="基本信息">
@@ -61,8 +61,9 @@
<field name="nation"/>
<field name="birthday"/>
<field name="old"/>
<field name="birthday_month"/>
<field name="user_type"/>
<field name="retire_data"/>
<field name="retire_date"/>
<field name="retire_years"/>
<field name="political_aspects"/>
<field name="dang_data"/>
@@ -72,26 +73,9 @@
<!-- 原字段的关联 暂时保留并隐藏 -->
<field name="country_of_birth" invisible="1"/>
</group>
<!-- 删除 与HR重复-->
<!-- <group string="工作信息">-->
<!-- <field name="new_start_contract_data"/>-->
<!-- <field name="new_end_contract_data"/>-->
<!-- <field name="open_start_time"/>-->
<!-- <field name="open_start_time_today"/>-->
<!-- <field name="interrupt_work_month"/>-->
<!-- <field name="cumulative_work_month"/>-->
<!-- <field name="cumulative_work_years"/>-->
<!-- </group>-->
<group string="教育">
<field name="high_degree"/>
<field name="high_degree2"/>
<field name="full_degree"/>
<field name="graduate_school"/>
<field name="profession"/>
<field name="graduate_date"/>
<field name="job_lv_date"/>
<field name="job_lv"/>
<field name="job_qualification_date"/>
<field name="job_lv_change"/>
<field name="move_note_date"/>
</group>
@@ -196,6 +180,8 @@
<field name="name_school"/>
<field name="start_date"/>
<field name="end_date"/>
<field name="Part_time_degree"/>
<field name="full_time_degree"/>
<field name="professional"/>
<field name="major_courses"/>
</tree>