diff --git a/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml b/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml index 9c9b88850..1ce651305 100644 --- a/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml +++ b/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml @@ -50,6 +50,10 @@ + + + @@ -108,9 +112,6 @@ - - @@ -862,7 +863,19 @@ code - action = model.all_put() + +# 先弹出确认向导,由用户在向导里二次确认后再真正发送 +action = { + 'type': 'ir.actions.act_window', + 'name': '发送确认提醒', + 'res_model': 'vacation.put.wizard', + 'view_mode': 'form', + 'target': 'new', + 'context': { + 'default_vacation_ids': [(6, 0, env.context.get('active_ids', []))], + }, +} + diff --git a/yuthon_hr_attendance/wizard/vacation_put_wizard.py b/yuthon_hr_attendance/wizard/vacation_put_wizard.py index 8b2a000c4..2353a6cf8 100644 --- a/yuthon_hr_attendance/wizard/vacation_put_wizard.py +++ b/yuthon_hr_attendance/wizard/vacation_put_wizard.py @@ -13,23 +13,22 @@ class VacationPutWizard(models.TransientModel): _name = 'vacation.put.wizard' _description = '批量发送弹窗' + # 选中的考勤确认单 vacation_ids = fields.Many2many('yuthon.vacation.reports', string='假期') + # 选中的不重复员工数量,用于弹窗展示 + employee_count = fields.Integer(string='员工人数', compute='_compute_employee_count') + + @api.depends('vacation_ids') + def _compute_employee_count(self): + """ 统计选中考勤单里不重复的员工数量 """ + for wizard in self: + wizard.employee_count = len(wizard.vacation_ids.mapped('employee_id')) def action_confirm(self): - employee_reports_map = {} - for report in self.vacation_ids: - if not report.employee_id: - continue - emp = report.employee_id - if emp not in employee_reports_map: - employee_reports_map[emp] = report - elif report.vacation_date > employee_reports_map[emp].vacation_date: - employee_reports_map[emp] = report - - # for employee, report in employee_reports_map.items(): - # we_id = employee.wecom_userid - # message = f"你{self.select_year}年{self.select_time}月的考勤确认单已经生成,请到手机端确认", - # if we_id: - # self.sudo().env["wecom.apps"].sync_send_message(category='att', user_id=we_id, message=message,) - # self.sudo().env["wecom.apps"].sync_send_message(category='att', user_id="18562027762", message=message,) - # self.write({'confirm_status': 'un_confirm'}) \ No newline at end of file + """ 用户确认后,把选中的记录通过 all_put 真正发送出去 """ + self.ensure_one() + # 没有选中记录时给出提示,避免空发送 + if not self.vacation_ids: + raise UserError(_('请先选择要发送的考勤确认单。')) + # 以 active_ids 的形式把选中记录传回 all_put,保持原有发送逻辑不变 + return self.vacation_ids.with_context(active_ids=self.vacation_ids.ids).all_put() \ No newline at end of file diff --git a/yuthon_hr_attendance/wizard/vacation_put_wizard_views.xml b/yuthon_hr_attendance/wizard/vacation_put_wizard_views.xml index 04e41d988..790527c27 100644 --- a/yuthon_hr_attendance/wizard/vacation_put_wizard_views.xml +++ b/yuthon_hr_attendance/wizard/vacation_put_wizard_views.xml @@ -4,18 +4,25 @@ vacation.put.wizard.form vacation.put.wizard - + - 只针对未确认的考勤确认单台账,确定要发送吗? + 确定要给 位员工发送考勤确认提醒吗? - + + + + + + + + - \ No newline at end of file +