添加功能
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from odoo import api, fields, models
|
||||
from datetime import datetime
|
||||
from odoo.exceptions import UserError, ValidationError
|
||||
|
||||
nation_list = [('a', '汉族'), ('b', '壮族'), ('v', '满族'), ('d', '回族'), ('e', '苗族'), ('f', '维吾尔族'),
|
||||
('g', '土家族'), ('h', '彝族'), ('i', '蒙古族'), ('j', '藏族'), ('k', '布依族'), ('l', '侗族'),
|
||||
@@ -34,7 +35,7 @@ class YuthonHrEmployee(models.Model):
|
||||
confirmation_date = fields.Date(string="转正时间")
|
||||
company_old = fields.Char(string="司龄", compute='_compute_company_old')
|
||||
user_sex = fields.Selection([('girl', '女'), ('boy', '男')], string="性别")
|
||||
user_state = fields.Selection([('in', '在职'), ('leave', '离职'), ('withdraw', '退休')], string="员工状态")
|
||||
user_state = fields.Selection([('in', '在职'), ('leave', '离职'), ('withdraw', '退休')], string="员工状态",compute='_compute_user_state')
|
||||
user_number_start_time = fields.Date(string="身份中有效开始时间")
|
||||
user_number_end_time = fields.Date(string="身份证有效到期时间")
|
||||
nation = fields.Selection(nation_list, string="民族")
|
||||
@@ -159,3 +160,16 @@ class YuthonHrEmployee(models.Model):
|
||||
record.retire_years = 0
|
||||
else:
|
||||
record.retire_years = 0
|
||||
|
||||
@api.depends('new_start_contract_data', 'new_end_contract_data')
|
||||
def _compute_user_state(self):
|
||||
for record in self:
|
||||
today = datetime.now().date()
|
||||
if record.new_start_contract_data >= record.new_end_contract_data:
|
||||
raise ValidationError('合同开始日期不能大于合同结束日期')
|
||||
if record.new_start_contract_data <= today <= record.new_end_contract_data:
|
||||
record.user_state = 'in'
|
||||
else:
|
||||
record.user_state = 'leave'
|
||||
|
||||
|
||||
|
||||
@@ -203,6 +203,35 @@
|
||||
<xpath expr="//field[@name='parent_id']" position="attributes">
|
||||
<attribute name="string">上级领导</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='job_id']" position="after">
|
||||
<field name="number" optional="hide"/>
|
||||
<field name="use_user_type" optional="hide"/>
|
||||
<field name="user_number" optional="hide"/>
|
||||
<field name="job_lv_id" optional="hide"/>
|
||||
<field name="entry_date" optional="hide"/>
|
||||
<field name="confirmation_date" optional="hide"/>
|
||||
<field name="company_old" optional="hide"/>
|
||||
<field name="user_number_start_time" optional="hide"/>
|
||||
<field name="nation" optional="hide"/>
|
||||
<field name="user_sex" optional="hide"/>
|
||||
<field name="old" optional="hide"/>
|
||||
<field name="birthday_month" optional="hide"/>
|
||||
<field name="user_type" optional="hide"/>
|
||||
<field name="retire_years" optional="hide"/>
|
||||
<field name="political_aspects" optional="hide"/>
|
||||
<field name="dang_data" optional="hide"/>
|
||||
<field name="new_start_contract_data" optional="hide"/>
|
||||
<field name="open_start_time" optional="hide"/>
|
||||
<field name="open_start_time_today" optional="hide"/>
|
||||
<field name="interrupt_work_month" optional="hide"/>
|
||||
<field name="cumulative_work_month" optional="hide"/>
|
||||
<field name="cumulative_work_years" optional="hide"/>
|
||||
<field name="high_degree" optional="hide"/>
|
||||
<field name="high_degree2" optional="hide"/>
|
||||
<field name="profession" optional="hide"/>
|
||||
<field name="graduate_date" optional="hide"/>
|
||||
<field name="graduate_school" optional="hide"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -213,4 +242,44 @@
|
||||
<field name="state">code</field>
|
||||
<field name="code">action = model.action_hr_employee()</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="yuthon_hr_employee_in_action" model="ir.actions.act_window">
|
||||
<field name="name">在职</field>
|
||||
<field name="res_model">hr.employee</field>
|
||||
<field name="view_mode">kanban,tree,form</field>
|
||||
<field name="domain">[('user_state','=','in')]</field>
|
||||
</record>
|
||||
|
||||
<record id="yuthon_hr_employee_leave_action" model="ir.actions.act_window">
|
||||
<field name="name">离职</field>
|
||||
<field name="res_model">hr.employee</field>
|
||||
<field name="view_mode">kanban,tree,form</field>
|
||||
<field name="domain">[('user_state','=','leave')]</field>
|
||||
</record>
|
||||
|
||||
<record id="yuthon_hr_employee_withdraw_action" model="ir.actions.act_window">
|
||||
<field name="name">退休</field>
|
||||
<field name="res_model">hr.employee</field>
|
||||
<field name="view_mode">kanban,tree,form</field>
|
||||
<field name="domain">[('user_state','=','withdraw')]</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="yuthon_hr_employee_in_menu"
|
||||
sequence="1"
|
||||
parent="hr.menu_hr_employee_user"
|
||||
name="在职"
|
||||
action="yuthon_hr_employee_in_action"/>
|
||||
|
||||
<menuitem id="yuthon_hr_employee_leave_menu"
|
||||
name="离职"
|
||||
sequence="3"
|
||||
parent="hr.menu_hr_employee_user"
|
||||
action="yuthon_hr_employee_leave_action"/>
|
||||
|
||||
<menuitem id="yuthon_hr_employee_withdraw_menu"
|
||||
sequence="5"
|
||||
name="退休"
|
||||
parent="hr.menu_hr_employee_user"
|
||||
action="yuthon_hr_employee_withdraw_action"/>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user