diff --git a/yuthon_holiday/models/yuthon_breastfeed_leave.py b/yuthon_holiday/models/yuthon_breastfeed_leave.py index 851e7beb7..cd3730db4 100644 --- a/yuthon_holiday/models/yuthon_breastfeed_leave.py +++ b/yuthon_holiday/models/yuthon_breastfeed_leave.py @@ -27,3 +27,18 @@ class YuthonBreastfeedLeave(models.Model): name_title = fields.Char(default=_get_default_name_title) self_users_ids = fields.Many2many('res.users', string="当前经办人", default=lambda self: [(6, 0, [self.env.user.id])]) + + def end_approval(self): + self.ensure_one() + employee = self.users_id.employee_id + breastfeeding_type = '1' if self.time_slot_selection == 'morning' else '2' + self.env['breastfeeding.holiday'].create({ + 'resource_calendar_id': employee.resource_calendar_id.id, + 'employee_id': employee.id, + 'breastfeeding_type': breastfeeding_type, + 'calendar_start_time': self.start_date, + 'calendar_end_time': self.end_date, + 'check_in': 9, + 'check_out': 16, + }) + self.write({'work_end': True}) diff --git a/yuthon_holiday/models/yuthon_fixes_approval.py b/yuthon_holiday/models/yuthon_fixes_approval.py index cc60f5a60..c52b70b6a 100644 --- a/yuthon_holiday/models/yuthon_fixes_approval.py +++ b/yuthon_holiday/models/yuthon_fixes_approval.py @@ -43,7 +43,7 @@ class YuthonFixesApproval(models.Model): @api.onchange('holiday_status') def _onchange_holiday_status(self): - if self.holiday_status: + if self.holiday_status and self.vacation_id: if self.holiday_status == 'annual': self.original_hours = self.vacation_id.leave else: diff --git a/yuthon_hr_attendance/models/hr_attendance.py b/yuthon_hr_attendance/models/hr_attendance.py index b82a031a4..593a8fc6f 100644 --- a/yuthon_hr_attendance/models/hr_attendance.py +++ b/yuthon_hr_attendance/models/hr_attendance.py @@ -489,20 +489,49 @@ class HrAttendance(models.Model): "view_mode": "form", "target": "new", "context": { - "default_attendance_id": self.id + "default_attendance_ids": [(6, 0, [self.id])] } } - - def button_compensatory_leave(self): - form_id = self.env.ref('yuthon_hr_attendance.view_yuthon_adjustments_approval_form').id + def all_button_correct_wizard(self): + self.approval_check_in = self.check_in + self.approval_check_out = self.check_out + self.is_approval_no = self.is_no_card + self.is_approval_early = self.is_early_card + self.is_approval_late = self.is_late_card + self.is_approval_abnormal = self.is_abnormal + self.is_approval_abs = self.absenteeism_card return { "type": "ir.actions.act_window", - "name": "调休申请", - "res_model": "yuthon.adjustments.approval", - "views": [[form_id, "form"]], + "name": "修正弹窗", + "res_model": "attendance.correct.wizard", + "view_mode": "form", + "target": "new", "context": { - 'default_users_id': self.employee_id.user_id.id, + "default_attendance_ids": [(6, 0, [self.id])] + } + } + + def button_compensatory_leave(self): + attendance_ids = self.env["hr.attendance"].browse( + self._context.get('active_ids', self._context.get('active_id')) + ) + for record in attendance_ids: + record.approval_check_in = record.check_in + record.approval_check_out = record.check_out + record.is_approval_no = record.is_no_card + record.is_approval_early = record.is_early_card + record.is_approval_late = record.is_late_card + record.is_approval_abnormal = record.is_abnormal + record.is_approval_abs = record.absenteeism_card + return { + "type": "ir.actions.act_window", + "name": "修正弹窗", + "res_model": "attendance.correct.wizard", + "view_mode": "form", + "target": "new", + "context": { + "default_attendance_ids": [(6, 0, attendance_ids.ids)] } } diff --git a/yuthon_hr_attendance/views/hr_attendance_views.xml b/yuthon_hr_attendance/views/hr_attendance_views.xml index 882b90e5b..280124b8b 100644 --- a/yuthon_hr_attendance/views/hr_attendance_views.xml +++ b/yuthon_hr_attendance/views/hr_attendance_views.xml @@ -18,7 +18,9 @@ btn-primary"/>-->