字段修改employee 2.0

This commit is contained in:
ONION
2024-08-19 14:13:02 +08:00
parent e34b55d31f
commit 31ef7f47f6
3 changed files with 51 additions and 54 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="主修课程")
+45 -35
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', '侗族'),
@@ -31,15 +32,16 @@ class YuthonHrEmployee(models.Model):
job_lv_salary = fields.Float(string="职级工资")
entry_date = fields.Date(string="入职时间")
confirmation_date = fields.Date(string="转正时间")
company_old = fields.Integer(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="离退休年限")
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="籍贯")
@@ -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
@@ -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,27 +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>
@@ -197,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>