From 00ccb455e41d1700057494bc3e29f69f90448944 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= Date: Thu, 5 Mar 2026 21:53:13 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=83=E5=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/yuthon_vacation_reports.py | 33 +++++++++++++++++++ .../views/yuthon_vacation_reports_views.xml | 14 ++++++++ 2 files changed, 47 insertions(+) diff --git a/yuthon_hr_attendance/models/yuthon_vacation_reports.py b/yuthon_hr_attendance/models/yuthon_vacation_reports.py index dabcbff7b..6f9039200 100644 --- a/yuthon_hr_attendance/models/yuthon_vacation_reports.py +++ b/yuthon_hr_attendance/models/yuthon_vacation_reports.py @@ -48,6 +48,11 @@ class YuthonVacationReports(models.Model): late_allowed = fields.Float(related="employee_id.late_allowed", string="允许迟到次数") leave_ids = fields.One2many('vacation.leave.line', 'vacation_id', string='年假明细') overtime_ids = fields.One2many('vacation.over.line', 'vacation_id', string='加班明细') + # 加班明细合计字段 + overtime_workday_total = fields.Float(string='工作日合计', compute='_compute_overtime_totals', digits=(16, 1)) + overtime_legal_day_total = fields.Float(string='法定节假日合计', compute='_compute_overtime_totals', digits=(16, 1)) + overtime_public_holidays_total = fields.Float(string='公休日合计', compute='_compute_overtime_totals', digits=(16, 1)) + overtime_grand_total = fields.Float(string='总合计', compute='_compute_overtime_totals', digits=(16, 1)) meal_fee_ids = fields.One2many('vacation.meal.line', 'vacation_id', string='误餐明细') medical_fee_ids = fields.One2many('vacation.medical.line', 'vacation_id', string='体检费明细') parenting_line_ids = fields.One2many('vacation.parenting.line', 'vacation_id', string='育儿假明细') @@ -1406,6 +1411,34 @@ class YuthonVacationReports(models.Model): record.statutory_leave = legal_total/8 record.cop_leave = total_add2 / 8 + @api.depends('overtime_ids.workday', 'overtime_ids.legal_day', 'overtime_ids.public_holidays', 'overtime_ids.update_type', 'overtime_ids.is_void') + def _compute_overtime_totals(self): + """计算加班明细的合计:工作日、法定节假日、公休日的合计,以及总合计 + 根据update_type判断是增加还是减少 + """ + for record in self: + workday_total = 0.0 + legal_day_total = 0.0 + public_holidays_total = 0.0 + + for line in record.overtime_ids: + if line.is_void: + continue + + if line.update_type == 'add': + workday_total += line.workday or 0 + legal_day_total += line.legal_day or 0 + public_holidays_total += line.public_holidays or 0 + elif line.update_type == 'reduce': + workday_total -= line.workday or 0 + legal_day_total -= line.legal_day or 0 + public_holidays_total -= line.public_holidays or 0 + + record.overtime_workday_total = workday_total + record.overtime_legal_day_total = legal_day_total + record.overtime_public_holidays_total = public_holidays_total + record.overtime_grand_total = workday_total + legal_day_total + public_holidays_total + @api.depends('meal_fee_ids.update_lines', 'meal_fee_ids.update_type', 'meal_fee_ids.is_void') def _compute_meal_fee(self): for record in self: diff --git a/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml b/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml index 3baa0fdc5..ccd48943b 100644 --- a/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml +++ b/yuthon_hr_attendance/views/yuthon_vacation_reports_views.xml @@ -249,6 +249,20 @@