From 12baf79860ab4999acabcbc879a98cfa9053fd01 Mon Sep 17 00:00:00 2001 From: zhou <123@> Date: Thu, 3 Jul 2025 12:50:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yuthon_contract/models/inherit_hr_contract.py | 27 ++++++++++++++----- .../views/inherit_hr_contract_views.xml | 7 +++++ .../models/yuthon_hr_employee.py | 6 +++++ yuthon_salary/models/inherit_hr_payslip.py | 7 +++-- .../views/inherit_hr_payslip_views.xml | 1 + 5 files changed, 39 insertions(+), 9 deletions(-) diff --git a/yuthon_contract/models/inherit_hr_contract.py b/yuthon_contract/models/inherit_hr_contract.py index 7c31a1ffa..b58693c73 100644 --- a/yuthon_contract/models/inherit_hr_contract.py +++ b/yuthon_contract/models/inherit_hr_contract.py @@ -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') diff --git a/yuthon_contract/views/inherit_hr_contract_views.xml b/yuthon_contract/views/inherit_hr_contract_views.xml index 93f9cdff9..7cb7b5339 100644 --- a/yuthon_contract/views/inherit_hr_contract_views.xml +++ b/yuthon_contract/views/inherit_hr_contract_views.xml @@ -26,11 +26,18 @@ + + 0 + + + + 1 + diff --git a/yuthon_hr_employee/models/yuthon_hr_employee.py b/yuthon_hr_employee/models/yuthon_hr_employee.py index 94585a58e..675b31ab2 100644 --- a/yuthon_hr_employee/models/yuthon_hr_employee.py +++ b/yuthon_hr_employee/models/yuthon_hr_employee.py @@ -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 diff --git a/yuthon_salary/models/inherit_hr_payslip.py b/yuthon_salary/models/inherit_hr_payslip.py index 58af99e00..071fe4cd2 100644 --- a/yuthon_salary/models/inherit_hr_payslip.py +++ b/yuthon_salary/models/inherit_hr_payslip.py @@ -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 # 请假扣发 ) diff --git a/yuthon_salary/views/inherit_hr_payslip_views.xml b/yuthon_salary/views/inherit_hr_payslip_views.xml index eda253cff..ff0f2bf75 100644 --- a/yuthon_salary/views/inherit_hr_payslip_views.xml +++ b/yuthon_salary/views/inherit_hr_payslip_views.xml @@ -291,6 +291,7 @@ +