!3646 添加功能

Merge pull request !3646 from 李鹏宇/dev_zhou
This commit is contained in:
李鹏宇
2025-07-03 04:52:00 +00:00
committed by Gitee
5 changed files with 39 additions and 9 deletions
+20 -7
View File
@@ -21,6 +21,8 @@ class HrContract(models.Model):
date_of_entry = fields.Date(related='employee_id.entry_date', string="入职时间")
salary_group_id = fields.Many2one('yuthon.salary.group', string="工资单分组", store=True, index=True)
is_internship = fields.Boolean(string="实习期", compute='_compute_name', store=True)
date_end = fields.Date(string="合同结束时间", compute='_compute_date_end', store=True)
termination_date = fields.Date(string="合同中止时间")
work_entry_source = fields.Selection([
('calendar', '考勤安排'),
('attendance', 'Attendances'),
@@ -39,6 +41,14 @@ class HrContract(models.Model):
documents_ids = fields.Many2many('ir.attachment', string="合同附件")
is_company = fields.Boolean(string="本公司", default=True, compute='_compute_is_company', search='_search_part_of_company')
@api.depends('employee_id')
def _compute_date_end(self):
for record in self:
if record.employee_id.retire_date:
record.date_end = record.employee_id.retire_date
else:
record.date_end = date(2070, 1, 1)
def write(self, vals):
"""在写入时自动更新合同状态"""
today = fields.Date.today()
@@ -87,13 +97,16 @@ class HrContract(models.Model):
('state', 'not in', ['cancel']),
])
for contract in active_contracts:
if not contract.date_end:
contract.state = 'open'
else:
if contract.date_end < today:
contract.state = 'close'
else:
contract.state = 'open'
new_state = 'open' if not contract.date_end or contract.date_end >= today else 'close'
if new_state == 'open':
conflicting_contracts = self.search([
('id', '!=', contract.id),
('employee_id', '=', contract.employee_id.id),
('state', '=', 'open'),
])
if conflicting_contracts:
continue
contract.state = new_state
@api.depends_context('uid', 'company')
@api.depends('company_id')
@@ -26,11 +26,18 @@
<xpath expr="//field[@name='employee_id']" position="after">
<field name="code"/>
</xpath>
<xpath expr="//field[@name='date_end']" position="attributes">
<attribute name="readonly">0</attribute>
</xpath>
<xpath expr="//field[@name='date_end']" position="after">
<field name="termination_date"/>
</xpath>
<xpath expr="//page[@name='other']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='contract_type_id']" position="after">
<field name="is_probation"/>
<field name="termination_date"/>
<field name="salary_day" invisible="not is_internship"/>
<field name="salary_group_id" options="{'no_create': True}"/>
<field name="is_internship" invisible="1"/>
@@ -239,6 +239,12 @@ class YuthonHrEmployee(models.Model):
)
if has_fire_certificate:
amount += 50
quality = any(
cert.rank_name == '质检证书'
for cert in record.skills_certificates_ids
)
if quality and department_name == '仓储组':
amount += 100
if department_name == '领导班子':
record.security_amount = 0
+5 -2
View File
@@ -118,13 +118,15 @@ class InheritHrPayslip(models.Model):
excellent_employees = fields.Float(string='优秀部门经理/员工奖励')
leave_absence = fields.Float(string='考勤补发')
# 粮储常用项
quality_allowance = fields.Float(string='质检员津贴')
environmental_allowance = fields.Float(string='环境作业津贴')
last_duty = fields.Float(string='上月值班费')
high_subsidy = fields.Float(string='高温补贴')
# 粮储临时项
medical_fee = fields.Float(string='超出体检费标准')
performance_deduction = fields.Float(string='扣发绩效奖金', compute='_compute_deduction', store=True)
commuting_deduction = fields.Float(string='扣发通信补贴', compute='_compute_deduction', store=True)
base_salary_deduction = fields.Float(string='扣发基本工资', compute='_compute_deduction', store=True)
@@ -281,7 +283,7 @@ class InheritHrPayslip(models.Model):
@api.depends('year_compute', 'year_jie', 'year_gong', 'jing_te', 'study_on', 'seniority_allowance', 'position_salary',
'quality_allowance','high_subsidy', 'environmental_allowance', 'last_duty', 'seniority_salary', 'commuting_allowance','base_salary','performance_bonuses', 'comprehensive_subsidy', 'full_attendance_award', 'overtime_pay', 'based_pay',
'january_performance','position_subsidy', 'safety_incentives', 'temporary_performance_bonus', 'performance_deduction','commuting_deduction',
'base_salary_deduction', 'last_year_performance_evaluation', 'safety_subsidy', 'job_performance','leave_allowance',
'base_salary_deduction', 'last_year_performance_evaluation', 'safety_subsidy', 'job_performance','leave_allowance', 'medical_fee',
'duty', 'monthly_overtime', 'annuity', 'excellent_employees', 'leave_absence', 'retention_previous_year')
def _compute_total_before_tax(self):
for record in self:
@@ -325,6 +327,7 @@ class InheritHrPayslip(models.Model):
record.performance_deduction -
record.commuting_deduction -
record.base_salary_deduction -
record.medical_fee -
record.leave_allowance # 请假扣发
)
@@ -291,6 +291,7 @@
<field name="year_gong" decoration-danger="1" optional="show" groups="yuthon_salary.group_jtbb_user"/>
<field name="study_on" decoration-danger="1" optional="show" groups="yuthon_salary.group_jtbb_user"/>
<field name="excellent_employees" decoration-danger="1" groups="yuthon_salary.group_wg_user" optional="show"/>
<field name="medical_fee" decoration-danger="1" groups="yuthon_salary.group_lc_user" optional="show"/>
<field name="commuting_deduction" decoration-danger="1" optional="show" groups="yuthon_salary.group_jtbb_user"/>
<field name="performance_deduction" decoration-danger="1" optional="show" groups="yuthon_salary.group_jtbb_user"/>
<field name="retention_previous_year" decoration-danger="1" optional="show" groups="yuthon_salary.group_jtbb_user"/>