添加功能

This commit is contained in:
李鹏宇
2025-12-30 16:58:14 +08:00
parent b3c5a6727e
commit 8d42470f97
@@ -117,7 +117,7 @@ class YuthonDutyPlan(models.Model):
for i in self.env['planning.slot'].search([('role_id.name', '=', '联安粮库'), ('template_id.planning_name', '=', '白班')]).sorted('start_datetime'):
date = i.start_datetime.date()
if not self.is_workday(date):
if not self.is_workday(date, current_date):
i.sudo().unlink()
other_data = {}
@@ -160,13 +160,21 @@ class YuthonDutyPlan(models.Model):
}
}
def is_workday(self, date):
def is_workday(self, date, current_date):
"""判断指定日期是否为工作日(考虑法定节假日和调休)
如果是工作日返回True
如果是休息日返回False
"""
calendar_leaves = self.env['resource.calendar.leaves'].sudo().search(
[("calendar_id", "=", "行政考勤工作日")])
current_year = current_date.year
original_year_start = datetime(current_year, 1, 1, 0, 0, 0)
original_year_end = datetime(current_year, 12, 31, 23, 59, 59)
query_start = original_year_start - timedelta(hours=8)
query_end = original_year_end - 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: