From 84135425f119b80b44aab0843c8006483a213152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=B9=8F=E5=AE=87?= <9664676+pengyuthon@user.noreply.gitee.com> Date: Wed, 17 Sep 2025 18:39:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/yuthon_vacation_reports.py | 26 ++----------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/yuthon_hr_attendance/models/yuthon_vacation_reports.py b/yuthon_hr_attendance/models/yuthon_vacation_reports.py index 89f85b374..4bc58f012 100644 --- a/yuthon_hr_attendance/models/yuthon_vacation_reports.py +++ b/yuthon_hr_attendance/models/yuthon_vacation_reports.py @@ -62,7 +62,7 @@ class YuthonVacationReports(models.Model): is_no_card = fields.Integer(string="缺卡", compute='compute_attendance_fields', store=True, group_operator=None) is_work = fields.Integer(string='旷工', compute='compute_attendance_fields', store=True, group_operator=None) is_abnormal = fields.Integer(string="异常", compute='compute_attendance_fields', store=True, group_operator=None) - att_mount = fields.Integer(string="出勤天数", compute='compute_att_mount', store=True, group_operator=None) + att_mount = fields.Integer(string="出勤天数", compute='compute_attendance_fields', store=True, group_operator=None) vacation_state = fields.Selection( @@ -91,29 +91,6 @@ class YuthonVacationReports(models.Model): f"已存在假期额度记录,不能重复创建!" ) - @api.depends('vacation_date', 'employee_id') - def compute_att_mount(self): - for record in self: - target_date = record.vacation_date or fields.Date.today().replace(day=1) - first_day = target_date.replace(day=1) - if target_date.month == 12: - next_month = 1 - next_year = target_date.year + 1 - else: - next_month = target_date.month + 1 - next_year = target_date.year - last_day = fields.Date.from_string(f"{next_year}-{next_month}-01") - timedelta(days=1) - - first_day_str = fields.Date.to_string(first_day) - last_day_str = fields.Date.to_string(last_day) - attendance_records = self.env['hr.attendance'].search([ - ('employee_id', '=', record.employee_id.id), - ('current_data', '>=', first_day_str), - ('current_data', '<=', last_day_str) - ]) - unique_dates = set(attendance_records.mapped('current_data')) - record.att_mount = len(unique_dates) - def action_open(self): self.ensure_one() target_date = self.vacation_date or fields.Date.today().replace(day=1) @@ -239,6 +216,7 @@ class YuthonVacationReports(models.Model): rec.is_work = is_work rec.is_abnormal = is_abnormal rec.actual_attendance = actual_attendance + rec.att_mount = actual_attendance def _compute_attendance_fields1(self):