diff --git a/yuthon_hr_attendance/models/vacation_overtime_active.py b/yuthon_hr_attendance/models/vacation_overtime_active.py index c6aca4336..25998e64d 100644 --- a/yuthon_hr_attendance/models/vacation_overtime_active.py +++ b/yuthon_hr_attendance/models/vacation_overtime_active.py @@ -165,6 +165,7 @@ class VacationOvertimeActive(models.Model): def open_record(self): self.ensure_one() import datetime + import math year = int(self.select_year) month = int(self.select_month) @@ -194,18 +195,15 @@ class VacationOvertimeActive(models.Model): records = self.env['overtime.carryover'].search(original_domain) total = sum(r.carry_forward_quantity for r in records) - # 2. 判断总和是否相等 - if abs(total - self.carry_forward_quantity) > 0.001: # 不相等 - # 只保留 fee 类型 + if math.isclose(total, self.carry_forward_quantity, abs_tol=1e-9): + final_domain = original_domain + else: final_domain = [ ('over_line_id.vacation_id.employee_id', '=', self.employee_id.id), ('is_void', '=', False), ('carryover_type', '=', 'fee'), ('carry_forward_date', '=', self.carry_forward_date), ] - else: - # 相等,用原来的 - final_domain = original_domain # 打开视图 view_id = self.env.ref('yuthon_hr_attendance.view_overtime_carryover_tree1').id