diff --git a/yuthon_holiday/models/inherit_hr_leave.py b/yuthon_holiday/models/inherit_hr_leave.py index c95329e9a..12b483b63 100644 --- a/yuthon_holiday/models/inherit_hr_leave.py +++ b/yuthon_holiday/models/inherit_hr_leave.py @@ -168,11 +168,24 @@ class HrLeave(models.Model): holiday.number_of_days = days if holiday.holiday_status_id.type_of_work == "0": calendar = self.env['resource.calendar'].sudo().search([("name", "=", "行政考勤工作日")], limit=1) - day, hours = holiday._get_duration(resource_calendar=calendar) - total_hours = (self.request_date_to - self.request_date_from).days - days = calendar.hours_per_day/8 * total_hours + 1 - holiday.number_of_hours = hours - holiday.number_of_days = days + calendar_leaves = self.env['resource.calendar.leaves'].search([]) + found = False + target_day = holiday.request_date_from + for leaves in calendar_leaves: + shift_days = leaves.shift_replacement_day.split(',') if leaves.shift_replacement_day else [] + for day_str in shift_days: + day = datetime.strptime(day_str, '%m月%d日') + if day.month == target_day.month and day.day == target_day.day: + hours = float(holiday.request_hour_to) - float(holiday.request_hour_from) -2 + holiday.number_of_hours = hours + found = True + break + if not found: + day, hours = holiday._get_duration(resource_calendar=calendar) + total_hours = (self.request_date_to - self.request_date_from).days + days = calendar.hours_per_day / 8 * total_hours + 1 + holiday.number_of_hours = hours + holiday.number_of_days = days def _compute_request_unit_hours(self): if not self.env.context.get('no_change_request_unit_hours'): diff --git a/yuthon_holiday/views/hr_leave_batch.xml b/yuthon_holiday/views/hr_leave_batch.xml index 668540c2b..476e5c22d 100644 --- a/yuthon_holiday/views/hr_leave_batch.xml +++ b/yuthon_holiday/views/hr_leave_batch.xml @@ -130,9 +130,9 @@ - + - code action = model.button_batch_correct() - + + 批量更新班次 + + + code + action = model.update_shift() + 测试删除