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 dd06dc58f..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', '侗族'),
@@ -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
diff --git a/yuthon_hr_employee/views/yuthon_hr_employee_views.xml b/yuthon_hr_employee/views/yuthon_hr_employee_views.xml
index 67c656a3b..820188aac 100644
--- a/yuthon_hr_employee/views/yuthon_hr_employee_views.xml
+++ b/yuthon_hr_employee/views/yuthon_hr_employee_views.xml
@@ -49,8 +49,8 @@
-
-
+
+
@@ -61,8 +61,9 @@
+
-
+
@@ -72,26 +73,9 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -196,6 +180,8 @@
+
+