diff --git a/yuthon_hr_attendance/models/yuthon_vacation_reports.py b/yuthon_hr_attendance/models/yuthon_vacation_reports.py index 31323f057..9479eeda1 100644 --- a/yuthon_hr_attendance/models/yuthon_vacation_reports.py +++ b/yuthon_hr_attendance/models/yuthon_vacation_reports.py @@ -23,7 +23,7 @@ class YuthonVacationReports(models.Model): vacation_date = fields.Date(string='日期', default=lambda self: fields.Date.today()) leave = fields.Char(string='年假', compute='_compute_leave', store=True, digits=(16, 3)) - working_overtime = fields.Char(string='加班时', compute='_compute_working_overtime', store=True) + working_overtime = fields.Char(string='加班时', compute='_compute_working_overtime', store=True, digits=(16, 3)) meal_fee = fields.Integer(string="误餐次数", compute='_compute_meal_fee', store=True) medical_fee = fields.Float(string="体检费", compute='_compute_medical_fee', store=True) compensatory_leave = fields.Integer(string="调休") @@ -42,6 +42,10 @@ class YuthonVacationReports(models.Model): hospital_sick_leave = fields.Float(string='病假(住院期)') recovery_sick_leave = fields.Float(string='病假(出院恢复期)') exam_leave = fields.Integer(string='考试假') + right_days = fields.Float(string='转正天数') + internship_days = fields.Float(string='实习天数') + should_attendance = fields.Integer(string="应到") + actual_attendance = fields.Integer(string="实到") is_late_card = fields.Integer(string="迟到", compute='_compute_attendance_fields', store=True) is_early_card = fields.Integer(string="早退", compute='_compute_attendance_fields', store=True) @@ -153,11 +157,13 @@ class YuthonVacationReports(models.Model): today = fields.Date.today() employees = self.env['hr.employee'].search([]) for employee in employees: + resource_user_ids = employee.resource_calendar_id.resource_user_ids.ids + is_resource_user = True if employee.id in resource_user_ids else False existing_record = self.search([ ('employee_id', '=', employee.id), ('vacation_date', '=', today) ], limit=1) - if not existing_record: + if not existing_record and not is_resource_user: self.create({ 'employee_id': employee.id, 'vacation_date': today, @@ -179,7 +185,6 @@ class YuthonVacationReports(models.Model): self.create({ 'employee_id': employee.id, 'vacation_date': report_date, - # 计算字段会自动触发,无需手动设置 }) def overtime_allocation(self): @@ -212,9 +217,8 @@ class YuthonVacationReports(models.Model): elif line.update_type == 'reduce': leave_hours -= line_value leave_days = leave_hours / 8 - record.leave = f"{leave_hours:.2f}小时({leave_days:.2f}天)" + record.leave = f"{leave_days:.3f}" - # 2. 计算加班时(复用原有逻辑) overtime_hours = 0.0 for line in record.overtime_ids: if not line.is_void: @@ -224,7 +228,7 @@ class YuthonVacationReports(models.Model): elif line.update_type == 'reduce': overtime_hours -= line_total overtime_days = overtime_hours / 8 - record.working_overtime = f"{overtime_hours:.2f}小时({overtime_days:.2f}天)" + record.working_overtime = f"{overtime_days:.3f}" def vacation_delete(self): vacation_ids = self.env["yuthon.vacation.reports"].browse( @@ -264,7 +268,7 @@ class YuthonVacationReports(models.Model): leave_hours -= line_value leave_days = leave_hours / 8 - record.leave = f"{leave_hours:.2f}小时({leave_days:.2f}天)" + record.leave = f"{leave_days:.2f}" @api.depends( 'overtime_ids.workday', @@ -284,7 +288,7 @@ class YuthonVacationReports(models.Model): elif line.update_type == 'reduce': overtime_hours -= line_total overtime_days = overtime_hours / 8 - record.working_overtime = f"{overtime_hours:.2f}小时({overtime_days:.2f}天)" + record.working_overtime = f"{overtime_days:.2f}" @api.depends('meal_fee_ids.update_lines', 'meal_fee_ids.update_type', 'meal_fee_ids.is_void') def _compute_meal_fee(self): diff --git a/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml b/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml index dc1447cc2..97ae7de78 100644 --- a/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml +++ b/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml @@ -9,30 +9,35 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + +