!8322 添加功能

Merge pull request !8322 from 李鹏宇/dev_zhou
This commit is contained in:
李鹏宇
2026-01-26 08:54:46 +00:00
committed by Gitee
+27 -7
View File
@@ -851,13 +851,33 @@ class HolidaysRequestBatch(models.Model):
current_date = fields.Date.today()
vacation_date = current_date
for record in self:
reports_id = self.env['yuthon.vacation.reports'].search([('employee_id', '=', record.users_id.employee_ids.id),
('vacation_date', '=', vacation_date.replace(day=1))
], limit=1)
if reports_id:
record.holiday_allowance = (f"本年剩余(年假){reports_id.remainder_year:.3f}天, 上年剩余(年假){reports_id.previous_year:.3f}天\n"
f"本年剩余(补休){reports_id.remainder_year1:.3f}天, 上年剩余(补休){reports_id.previous_year1:.3f}天\n "
f"育儿假{reports_id.remaining_parental_leave:.3f}天")
result_parts = []
reports_id = self.env['yuthon.vacation.reports'].search([
('employee_id', '=', record.users_id.employee_ids.id),
('vacation_date', '=', vacation_date.replace(day=1))
], limit=1)
if not reports_id:
record.holiday_allowance = ""
continue
holiday_configs = [
("年假", "previous_year", "remainder_year"),
("补休", "previous_year1", "remainder_year1"),
("育儿假", None, "remaining_parental_leave")
]
for name, prev_field, curr_field in holiday_configs:
parts = []
if prev_field:
prev_value = getattr(reports_id, prev_field, 0.0)
if prev_value > 0: # 大于0才显示
parts.append(f"上年结余{prev_value:.0f}天")
curr_value = getattr(reports_id, curr_field, 0.0)
if curr_value > 0:
parts.append(f"本年剩余{curr_value:.0f}天")
if parts:
result_parts.append(f"{name}:{','.join(parts)}")
record.holiday_allowance = "\n".join(result_parts)
def action_print_leave_batch(self):
"""按钮触发打印请假单"""