From 31ef7f47f6fc3bea1ff64f2086bc5b3096b3fcf2 Mon Sep 17 00:00:00 2001
From: ONION <2275333053@qq.com>
Date: Mon, 19 Aug 2024 14:13:02 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E6=AE=B5=E4=BF=AE=E6=94=B9employee=20?=
=?UTF-8?q?2.0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
yuthon_hr_employee/models/hr_employee_page.py | 2 +
.../models/yuthon_hr_employee.py | 80 +++++++++++--------
.../views/yuthon_hr_employee_views.xml | 23 +-----
3 files changed, 51 insertions(+), 54 deletions(-)
diff --git a/yuthon_hr_employee/models/hr_employee_page.py b/yuthon_hr_employee/models/hr_employee_page.py
index c7e2eb037..41b198132 100644
--- a/yuthon_hr_employee/models/hr_employee_page.py
+++ b/yuthon_hr_employee/models/hr_employee_page.py
@@ -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="主修课程")
diff --git a/yuthon_hr_employee/models/yuthon_hr_employee.py b/yuthon_hr_employee/models/yuthon_hr_employee.py
index 9d32371f8..73aa1bbc8 100644
--- a/yuthon_hr_employee/models/yuthon_hr_employee.py
+++ b/yuthon_hr_employee/models/yuthon_hr_employee.py
@@ -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
diff --git a/yuthon_hr_employee/views/yuthon_hr_employee_views.xml b/yuthon_hr_employee/views/yuthon_hr_employee_views.xml
index 2cb51c890..820188aac 100644
--- a/yuthon_hr_employee/views/yuthon_hr_employee_views.xml
+++ b/yuthon_hr_employee/views/yuthon_hr_employee_views.xml
@@ -61,8 +61,9 @@
+
-
+
@@ -72,27 +73,9 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -197,6 +180,8 @@
+
+