!5206 添加功能

Merge pull request !5206 from 李鹏宇/zhou
This commit is contained in:
李鹏宇
2025-09-17 10:40:25 +00:00
committed by Gitee
@@ -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):