From 915984abc6690da8a1e73bb675f6033b4ca4ef4e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?=
<9664676+pengyuthon@user.noreply.gitee.com>
Date: Tue, 30 Dec 2025 17:42: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_catering/models/yuthon_catering.py | 9 +++++++-
yuthon_holiday/models/inherit_hr_leave.py | 9 +++++++-
.../controllers/applet_attendance.py | 17 +++++++++++---
yuthon_hr_attendance/models/hr_attendance.py | 23 ++++++++++++++++---
.../models/hr_attendance_detail_wechat.py | 9 +++++++-
.../models/hr_attendance_month.py | 9 +++++++-
.../models/message_reminder_tasks.py | 9 +++++++-
.../models/overtime_approval.py | 7 +++++-
.../models/yuthon_vacation_reports.py | 23 +++++++++++++++----
.../views/yuthon_vacation_reports_views.xml | 10 ++++----
.../wizard/hr_attendance_month_wizard.py | 9 +++++++-
.../views/contract_review_approval_views.xml | 2 +-
yuthon_salary/wizard/salary_compute_wizard.py | 9 +++++++-
.../views/yuthon_business_approval_viwes.xml | 2 +-
.../views/yuthon_message_approval_views.xml | 2 +-
15 files changed, 123 insertions(+), 26 deletions(-)
diff --git a/yuthon_catering/models/yuthon_catering.py b/yuthon_catering/models/yuthon_catering.py
index 7c28c1015..26a1d586e 100644
--- a/yuthon_catering/models/yuthon_catering.py
+++ b/yuthon_catering/models/yuthon_catering.py
@@ -50,7 +50,14 @@ class YuthonCatering(models.Model):
"""
判断是否是工作日 调休日 双休
"""
- calendar_leaves = self.env['resource.calendar.leaves'].search([("calendar_id", "=", "行政考勤工作日")])
+ current_year = (fields.Date.today() + timedelta(hours=8)).year
+ query_start = datetime(current_year, 1, 1, 0, 0, 0) - timedelta(hours=8)
+ query_end = datetime(current_year, 12, 31, 23, 59, 59) - timedelta(hours=8)
+ calendar_leaves = self.env['resource.calendar.leaves'].sudo().search([
+ ("calendar_id.name", "=", "行政考勤工作日"),
+ ("date_from", ">=", query_start),
+ ("date_from", "<=", query_end)
+ ])
holidays_list = []
shift_days_list = []
# 提取节假日和调休日
diff --git a/yuthon_holiday/models/inherit_hr_leave.py b/yuthon_holiday/models/inherit_hr_leave.py
index e1d7e6d9c..b74c82d5b 100644
--- a/yuthon_holiday/models/inherit_hr_leave.py
+++ b/yuthon_holiday/models/inherit_hr_leave.py
@@ -593,7 +593,14 @@ class HolidaysRequestBatch(models.Model):
days = 0
return days
if holiday_status_id.type_of_work == "0":
- calendar_leaves = self.env['resource.calendar.leaves'].search([("calendar_id", "=", "行政考勤工作日")])
+ current_year = (fields.Date.today() + timedelta(hours=8)).year
+ query_start = datetime(current_year, 1, 1, 0, 0, 0) - timedelta(hours=8)
+ query_end = datetime(current_year, 12, 31, 23, 59, 59) - timedelta(hours=8)
+ calendar_leaves = self.env['resource.calendar.leaves'].sudo().search([
+ ("calendar_id.name", "=", "行政考勤工作日"),
+ ("date_from", ">=", query_start),
+ ("date_from", "<=", query_end)
+ ])
holidays_list = []
shift_days_list = []
# 提取节假日和调休日
diff --git a/yuthon_hr_attendance/controllers/applet_attendance.py b/yuthon_hr_attendance/controllers/applet_attendance.py
index ee783dc72..1c8913472 100644
--- a/yuthon_hr_attendance/controllers/applet_attendance.py
+++ b/yuthon_hr_attendance/controllers/applet_attendance.py
@@ -307,8 +307,14 @@ class AppletAttendance(Controller):
如果是工作日返回True
如果是休息日返回False
"""
- calendar_leaves = request.env['resource.calendar.leaves'].sudo().search(
- [("calendar_id", "=", "行政考勤工作日")])
+ current_year = (fields.Date.today() + timedelta(hours=8)).year
+ query_start = datetime(current_year, 1, 1, 0, 0, 0) - timedelta(hours=8)
+ query_end = datetime(current_year, 12, 31, 23, 59, 59) - timedelta(hours=8)
+ calendar_leaves = self.env['resource.calendar.leaves'].sudo().search([
+ ("calendar_id.name", "=", "行政考勤工作日"),
+ ("date_from", ">=", query_start),
+ ("date_from", "<=", query_end)
+ ])
holidays_set = set()
shift_days_set = set()
for leave in calendar_leaves:
@@ -757,7 +763,12 @@ class AppletAttendance(Controller):
# 从start_date中提取年份
target_year = start_date.year
target_month = start_date.month
- domain = [("calendar_id", "=", "行政考勤工作日")]
+ current_year = (fields.Date.today() + timedelta(hours=8)).year
+ query_start = datetime(current_year, 1, 1, 0, 0, 0) - timedelta(hours=8)
+ query_end = datetime(current_year, 12, 31, 23, 59, 59) - timedelta(hours=8)
+ domain = [("calendar_id", "=", "行政考勤工作日"),
+ ("date_from", ">=", query_start),
+ ("date_from", "<=", query_end)]
if start_date and end_date:
# 将date对象转换为datetime对象
start_datetime = datetime.combine(start_date, datetime.min.time())
diff --git a/yuthon_hr_attendance/models/hr_attendance.py b/yuthon_hr_attendance/models/hr_attendance.py
index 7b524f468..f3e79b824 100644
--- a/yuthon_hr_attendance/models/hr_attendance.py
+++ b/yuthon_hr_attendance/models/hr_attendance.py
@@ -338,7 +338,14 @@ class HrAttendance(models.Model):
"""
判断是否是工作日 调休日 双休
"""
- calendar_leaves = self.env['resource.calendar.leaves'].search([("calendar_id", "=", "行政考勤工作日")])
+ current_year = (fields.Date.today() + timedelta(hours=8)).year
+ query_start = datetime(current_year, 1, 1, 0, 0, 0) - timedelta(hours=8)
+ query_end = datetime(current_year, 12, 31, 23, 59, 59) - timedelta(hours=8)
+ calendar_leaves = self.env['resource.calendar.leaves'].sudo().search([
+ ("calendar_id.name", "=", "行政考勤工作日"),
+ ("date_from", ">=", query_start),
+ ("date_from", "<=", query_end)
+ ])
holidays_list = []
shift_days_list = []
# 提取节假日和调休日
@@ -1079,8 +1086,13 @@ class HrAttendance(models.Model):
continue
if record.current_data:
+ current_year = (fields.Date.today() + timedelta(hours=8)).year
+ query_start = datetime(current_year, 1, 1, 0, 0, 0) - timedelta(hours=8)
+ query_end = datetime(current_year, 12, 31, 23, 59, 59) - timedelta(hours=8)
leave_records = self.env['resource.calendar.leaves'].search([
- ("calendar_id.name", "=", "行政考勤工作日")
+ ("calendar_id.name", "=", "行政考勤工作日"),
+ ("date_from", ">=", query_start),
+ ("date_from", "<=", query_end)
])
# 检查是否为节假日
for leave in leave_records:
@@ -1168,8 +1180,13 @@ class HrAttendance(models.Model):
is_weekend = False
if record.current_data:
# 查询休假记录
+ current_year = (fields.Date.today() + timedelta(hours=8)).year
+ query_start = datetime(current_year, 1, 1, 0, 0, 0) - timedelta(hours=8)
+ query_end = datetime(current_year, 12, 31, 23, 59, 59) - timedelta(hours=8)
leave_records = self.env['resource.calendar.leaves'].search(
- [("calendar_id", "=", "行政考勤工作日")])
+ [("calendar_id.name", "=", "行政考勤工作日"),
+ ("date_from", ">=", query_start),
+ ("date_from", "<=", query_end)])
# 检查是否存在匹配的休假日期
for leave in leave_records:
if leave.date_from and leave.date_to:
diff --git a/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py b/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py
index ae5bb976b..64a8e6a1c 100644
--- a/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py
+++ b/yuthon_hr_attendance/models/hr_attendance_detail_wechat.py
@@ -461,7 +461,14 @@ class HrAttendanceDetail(models.Model):
"""
判断是否是工作日 调休日 双休
"""
- calendar_leaves = self.env['resource.calendar.leaves'].search([("calendar_id", "=", "行政考勤工作日")])
+ current_year = (fields.Date.today() + timedelta(hours=8)).year
+ query_start = datetime(current_year, 1, 1, 0, 0, 0) - timedelta(hours=8)
+ query_end = datetime(current_year, 12, 31, 23, 59, 59) - timedelta(hours=8)
+ calendar_leaves = self.env['resource.calendar.leaves'].sudo().search([
+ ("calendar_id.name", "=", "行政考勤工作日"),
+ ("date_from", ">=", query_start),
+ ("date_from", "<=", query_end)
+ ])
holidays_list = []
shift_days_list = []
# 提取节假日和调休日
diff --git a/yuthon_hr_attendance/models/hr_attendance_month.py b/yuthon_hr_attendance/models/hr_attendance_month.py
index e771e1cf0..7a4e85228 100644
--- a/yuthon_hr_attendance/models/hr_attendance_month.py
+++ b/yuthon_hr_attendance/models/hr_attendance_month.py
@@ -430,7 +430,14 @@ class HrAttendanceMonthDetail(models.Model):
days = 0
return days
if holiday_status_id.type_of_work == 0:
- calendar_leaves = self.env['resource.calendar.leaves'].search([("calendar_id", "=", "行政考勤工作日")])
+ current_year = (fields.Date.today() + timedelta(hours=8)).year
+ query_start = datetime.datetime(current_year, 1, 1, 0, 0, 0) - timedelta(hours=8)
+ query_end = datetime.datetime(current_year, 12, 31, 23, 59, 59) - timedelta(hours=8)
+ calendar_leaves = self.env['resource.calendar.leaves'].sudo().search([
+ ("calendar_id.name", "=", "行政考勤工作日"),
+ ("date_from", ">=", query_start),
+ ("date_from", "<=", query_end)
+ ])
holidays_list = []
shift_days_list = []
# 提取节假日和调休日
diff --git a/yuthon_hr_attendance/models/message_reminder_tasks.py b/yuthon_hr_attendance/models/message_reminder_tasks.py
index cc2cf25e3..c7837ff36 100644
--- a/yuthon_hr_attendance/models/message_reminder_tasks.py
+++ b/yuthon_hr_attendance/models/message_reminder_tasks.py
@@ -198,7 +198,14 @@ class MessageReminderTasks(models.Model):
"""
判断是否是工作日 调休日 双休
"""
- calendar_leaves = self.env['resource.calendar.leaves'].search([("calendar_id", "=", "行政考勤工作日")])
+ current_year = (fields.Date.today() + timedelta(hours=8)).year
+ query_start = datetime(current_year, 1, 1, 0, 0, 0) - timedelta(hours=8)
+ query_end = datetime(current_year, 12, 31, 23, 59, 59) - timedelta(hours=8)
+ calendar_leaves = self.env['resource.calendar.leaves'].sudo().search([
+ ("calendar_id.name", "=", "行政考勤工作日"),
+ ("date_from", ">=", query_start),
+ ("date_from", "<=", query_end)
+ ])
holidays_list = []
shift_days_list = []
# 提取节假日和调休日
diff --git a/yuthon_hr_attendance/models/overtime_approval.py b/yuthon_hr_attendance/models/overtime_approval.py
index ea290a287..29746e202 100644
--- a/yuthon_hr_attendance/models/overtime_approval.py
+++ b/yuthon_hr_attendance/models/overtime_approval.py
@@ -346,7 +346,12 @@ class OvertimeApprovals(models.Model):
raise UserError("开始时间不能晚于结束时间")
start_date = fields.Datetime.from_string(record.start_time)
end_date = fields.Datetime.from_string(record.end_time)
- public_holidays = self.env['resource.calendar.leaves'].search([("calendar_id", "=", "行政考勤工作日")])
+ current_year = (fields.Date.today() + timedelta(hours=8)).year
+ query_start = datetime(current_year, 1, 1, 0, 0, 0) - timedelta(hours=8)
+ query_end = datetime(current_year, 12, 31, 23, 59, 59) - timedelta(hours=8)
+ public_holidays = self.env['resource.calendar.leaves'].search([("calendar_id.name", "=", "行政考勤工作日"),
+ ("date_from", ">=", query_start),
+ ("date_from", "<=", query_end)])
for holiday in public_holidays:
holiday_start = fields.Datetime.from_string(holiday.date_from)
holiday_end = fields.Datetime.from_string(holiday.date_to)
diff --git a/yuthon_hr_attendance/models/yuthon_vacation_reports.py b/yuthon_hr_attendance/models/yuthon_vacation_reports.py
index 85f2f4b2d..b187fed72 100644
--- a/yuthon_hr_attendance/models/yuthon_vacation_reports.py
+++ b/yuthon_hr_attendance/models/yuthon_vacation_reports.py
@@ -343,9 +343,14 @@ class YuthonVacationReports(models.Model):
entry_date = employee_id.entry_date
# 调整日期范围:如果开始日期早于入职日期,则从入职日期开始计算
actual_start_date = max(start_date, entry_date) if entry_date else start_date
- calendar_leaves = self.env['resource.calendar.leaves'].search(
- [("calendar_id.name", "=", "行政考勤工作日")])
-
+ current_year = (fields.Date.today() + timedelta(hours=8)).year
+ query_start = datetime(current_year, 1, 1, 0, 0, 0) - timedelta(hours=8)
+ query_end = datetime(current_year, 12, 31, 23, 59, 59) - timedelta(hours=8)
+ calendar_leaves = self.env['resource.calendar.leaves'].sudo().search([
+ ("calendar_id.name", "=", "行政考勤工作日"),
+ ("date_from", ">=", query_start),
+ ("date_from", "<=", query_end)
+ ])
holidays_list = [] # 节假日列表
statutory_list = [] # 法定节假日列表
shift_days_list = [] # 调休日列表
@@ -1014,7 +1019,14 @@ class VacationMedicalLine(models.Model):
return record
def create_leave_record(self, start_date, end_date):
- calendar_leaves = self.env['resource.calendar.leaves'].search([("calendar_id", "=", "行政考勤工作日")])
+ current_year = (fields.Date.today() + timedelta(hours=8)).year
+ query_start = datetime(current_year, 1, 1, 0, 0, 0) - timedelta(hours=8)
+ query_end = datetime(current_year, 12, 31, 23, 59, 59) - timedelta(hours=8)
+ calendar_leaves = self.env['resource.calendar.leaves'].sudo().search([
+ ("calendar_id.name", "=", "行政考勤工作日"),
+ ("date_from", ">=", query_start),
+ ("date_from", "<=", query_end)
+ ])
holidays_list = []
shift_days_list = []
# 提取节假日和调休日
@@ -1066,6 +1078,9 @@ class VacationOtherLine(models.Model):
text = fields.Text(string='备注')
is_confirm = fields.Boolean(string="是否确认")
+ def action_void(self):
+ self.is_void = True
+
@api.model
def create(self, vals):
if vals.get('vacation_id'):
diff --git a/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml b/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml
index 1927673ff..b4c78197c 100644
--- a/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml
+++ b/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml
@@ -155,7 +155,7 @@
-
+
@@ -180,7 +180,7 @@
-
+
@@ -201,7 +201,7 @@
-
+
@@ -221,7 +221,7 @@
-
+
@@ -241,7 +241,7 @@
-
+
diff --git a/yuthon_hr_attendance/wizard/hr_attendance_month_wizard.py b/yuthon_hr_attendance/wizard/hr_attendance_month_wizard.py
index 0d9673b72..a0c99f719 100644
--- a/yuthon_hr_attendance/wizard/hr_attendance_month_wizard.py
+++ b/yuthon_hr_attendance/wizard/hr_attendance_month_wizard.py
@@ -163,7 +163,14 @@ class HrAttendanceMonthWizard(models.TransientModel):
# 创建用户记录传入日期来获取天数
def _create_leave_record(self, holiday_status_id, start_date, end_date):
if holiday_status_id.type_of_work == 0:
- calendar_leaves = self.env['resource.calendar.leaves'].search([("calendar_id", "=", "行政考勤工作日")])
+ current_year = (fields.Date.today() + timedelta(hours=8)).year
+ query_start = datetime.datetime(current_year, 1, 1, 0, 0, 0) - timedelta(hours=8)
+ query_end = datetime.datetime(current_year, 12, 31, 23, 59, 59) - timedelta(hours=8)
+ calendar_leaves = self.env['resource.calendar.leaves'].sudo().search([
+ ("calendar_id.name", "=", "行政考勤工作日"),
+ ("date_from", ">=", query_start),
+ ("date_from", "<=", query_end)
+ ])
holidays_list = []
shift_days_list = []
# 提取节假日和调休日
diff --git a/yuthon_hr_employee_approval/views/contract_review_approval_views.xml b/yuthon_hr_employee_approval/views/contract_review_approval_views.xml
index ca3d6e615..8fdd4d8d5 100644
--- a/yuthon_hr_employee_approval/views/contract_review_approval_views.xml
+++ b/yuthon_hr_employee_approval/views/contract_review_approval_views.xml
@@ -58,7 +58,7 @@
-
+
diff --git a/yuthon_salary/wizard/salary_compute_wizard.py b/yuthon_salary/wizard/salary_compute_wizard.py
index 56cbc4f8c..3120efc48 100644
--- a/yuthon_salary/wizard/salary_compute_wizard.py
+++ b/yuthon_salary/wizard/salary_compute_wizard.py
@@ -371,7 +371,14 @@ class SalaryComputeWizard(models.Model):
return chinese_months[month - 1]
def _process_shift_days(self, start_date, end_date):
- calendar_leaves = self.env['resource.calendar.leaves'].search([("calendar_id", "=", "行政考勤工作日")])
+ current_year = (fields.Date.today() + timedelta(hours=8)).year
+ query_start = datetime(current_year, 1, 1, 0, 0, 0) - timedelta(hours=8)
+ query_end = datetime(current_year, 12, 31, 23, 59, 59) - timedelta(hours=8)
+ calendar_leaves = self.env['resource.calendar.leaves'].sudo().search([
+ ("calendar_id.name", "=", "行政考勤工作日"),
+ ("date_from", ">=", query_start),
+ ("date_from", "<=", query_end)
+ ])
holidays_list = []
shift_days_list = []
diff --git a/yuthon_trade/views/yuthon_business_approval_viwes.xml b/yuthon_trade/views/yuthon_business_approval_viwes.xml
index a1246555a..b729bd79b 100644
--- a/yuthon_trade/views/yuthon_business_approval_viwes.xml
+++ b/yuthon_trade/views/yuthon_business_approval_viwes.xml
@@ -54,7 +54,7 @@
-
+
diff --git a/yuthon_trade/views/yuthon_message_approval_views.xml b/yuthon_trade/views/yuthon_message_approval_views.xml
index ab6ab5787..9a24249c4 100644
--- a/yuthon_trade/views/yuthon_message_approval_views.xml
+++ b/yuthon_trade/views/yuthon_message_approval_views.xml
@@ -50,7 +50,7 @@
-
+