From a635f47e231bfa805b0c79d2cb838e18745a916c Mon Sep 17 00:00:00 2001
From: zhou <123@>
Date: Thu, 17 Jul 2025 15:40:03 +0800
Subject: [PATCH 1/3] =?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_holiday/models/inherit_hr_leave.py | 8 +-
.../models/inherit_hr_leave_allocation.py | 43 +++++--
yuthon_holiday/views/hr_leave_batch.xml | 8 +-
.../models/property_split_approval.py | 111 +++++++++++++++---
.../views/property_split_approval_views.xml | 17 +--
yuthon_salary/models/inherit_hr_payslip.py | 5 +-
6 files changed, 159 insertions(+), 33 deletions(-)
diff --git a/yuthon_holiday/models/inherit_hr_leave.py b/yuthon_holiday/models/inherit_hr_leave.py
index d6c06caed..25b77f17a 100644
--- a/yuthon_holiday/models/inherit_hr_leave.py
+++ b/yuthon_holiday/models/inherit_hr_leave.py
@@ -148,6 +148,12 @@ class HrLeave(models.Model):
('22', '22:00'), ('22.5', '22:30'),
('23', '23:00'), ('23.5', '23:30')], string='结束时间')
+ def update_state(self):
+ leave_ids = self.env["hr.leave"].browse(
+ self._context.get('active_ids', self._context.get('active_id')))
+ for leave in leave_ids:
+ leave.state = 'draft'
+
@api.model
def create(self, vals):
allocation = super(HrLeave, self).create(vals)
@@ -201,7 +207,7 @@ class HrLeave(models.Model):
self.env['vacation.over.line'].create({
'vacation_id': reports_id.id,
'employee_id': employee.id,
- 'update_type': 'add',
+ 'update_type': 'reduce',
'workday': allocation.number_of_days * 8,
'legal_day': 0,
'public_holidays': 0,
diff --git a/yuthon_holiday/models/inherit_hr_leave_allocation.py b/yuthon_holiday/models/inherit_hr_leave_allocation.py
index b73e31872..8c7e107ac 100644
--- a/yuthon_holiday/models/inherit_hr_leave_allocation.py
+++ b/yuthon_holiday/models/inherit_hr_leave_allocation.py
@@ -106,11 +106,11 @@ class HrLeaveAllocation(models.Model):
@api.model
def create(self, vals):
allocation = super(HrLeaveAllocation, self).create(vals)
+ employee = allocation.employee_id
+ hours = allocation.number_of_hours_display
if allocation.holiday_status_id.name == '年假' and allocation.state == 'validate':
- employee = allocation.employee_id
- days = allocation.number_of_hours_display
employee.write({
- 'quota_issued': employee.quota_issued + days
+ 'quota_issued': employee.quota_issued + hours
})
reports_id = self.env['yuthon.vacation.reports'].search([
('employee_id', '=', employee.id)
@@ -120,10 +120,24 @@ class HrLeaveAllocation(models.Model):
'vacation_id': reports_id.id,
'update_type': 'add',
'update_date': fields.Datetime.now(),
- 'update_lines': days,
+ 'update_lines': hours,
'allocation_type': 'allocation',
'text': allocation.name
})
+ elif allocation.holiday_status_id.name == '补休':
+ reports_id = self.env['yuthon.vacation.reports'].search([
+ ('employee_id', '=', employee.id)
+ ], limit=1)
+ self.env['vacation.over.line'].create({
+ 'vacation_id': reports_id.id,
+ 'update_type': 'add',
+ 'update_date': fields.Datetime.now(),
+ 'workday': hours,
+ 'legal_day': 0,
+ 'public_holidays': 0,
+ 'meal_number': 0,
+ 'text': allocation.name
+ })
return allocation
def unlink(self):
@@ -132,20 +146,33 @@ class HrLeaveAllocation(models.Model):
# 检查是否有需要同步的员工记录
if record.employee_id and record.holiday_status_id.name == '年假':
employee = record.employee_id
- days = record.number_of_hours_display
+ hours = record.number_of_hours_display
lines_to_delete = self.env['vacation.leave.line'].search([
('vacation_id.employee_id', '=', employee.id),
('update_type', '=', 'add'),
- ('update_lines', '=', days),
+ ('update_lines', '=', hours),
('allocation_type', '=', 'allocation'),
('text', '=', record.name)
])
if lines_to_delete:
lines_to_delete.is_void = True
employee.write({
- 'quota_issued': employee.quota_issued - days
+ 'quota_issued': employee.quota_issued - hours
})
- return super(HrLeaveAllocation, self).unlink()
+ elif record.employee_id and record.holiday_status_id.name == '补休':
+ employee = record.employee_id
+ hours = record.number_of_hours_display
+ lines_to_delete = self.env['vacation.over.line'].search([
+ ('vacation_id.employee_id', '=', employee.id),
+ ('update_type', '=', 'add'),
+ ('workday', '=', hours),
+ ('text', '=', record.name)
+ ])
+ if lines_to_delete:
+ lines_to_delete.is_void = True
+
+ return super(HrLeaveAllocation, self).unlink()
+
def update_vacation(self):
leave_ids = self.env["hr.leave.allocation"].browse(
diff --git a/yuthon_holiday/views/hr_leave_batch.xml b/yuthon_holiday/views/hr_leave_batch.xml
index 051b08425..47321f615 100644
--- a/yuthon_holiday/views/hr_leave_batch.xml
+++ b/yuthon_holiday/views/hr_leave_batch.xml
@@ -215,7 +215,13 @@
[('employee_id.user_id', '=', uid)]
-
+
+ 初始化状态
+
+
+ code
+ action = model.update_state()
+