Merge pull request !12670 from 李鹏宇/dev
This commit is contained in:
李鹏宇
2026-08-18 11:05:40 +00:00
committed by Gitee
@@ -70,7 +70,7 @@ class YuthonVacationReports(models.Model):
used_this_year1 = fields.Float(string="本年已休d", digits=(16, 3))
company_id = fields.Many2one(related="employee_id.company_id", string="公司", store=True)
late_allowed = fields.Float(related="employee_id.late_allowed", string="允许迟到次数")
late_allowed = fields.Float(string="允许迟到次数", compute="_compute_late_allowed_fields", store=False)
leave_ids = fields.One2many('vacation.leave.line', 'vacation_id', string='年假明细')
overtime_ids = fields.One2many('vacation.over.line', 'vacation_id', string='加班明细')
# 加班明细合计字段
@@ -249,6 +249,28 @@ class YuthonVacationReports(models.Model):
record.duty = max(total_duty_count - duty_off_count, 0)
@api.depends('vacation_date', 'employee_id')
@api.depends('employee_id', 'vacation_date')
def _compute_late_allowed_fields(self):
for record in self:
# 每月发放:天河物管员工 3 次允许迟到次数,其余公司 0
if record.employee_id and record.employee_id.company_id.name == "天河物管":
grant = 3
else:
grant = 0
# 当月已使用的宽容迟到次数(is_late_allowed=True 的考勤记录数)
used = 0
if record.employee_id and record.vacation_date:
month_start = record.vacation_date.replace(day=1)
month_end = month_start + relativedelta(months=1)
used = self.env['hr.attendance'].search_count([
('employee_id', '=', record.employee_id.id),
('current_data', '>=', month_start),
('current_data', '<', month_end),
('is_late_allowed', '=', True),
])
# 允许迟到次数(剩余)= 发放 - 已用
record.late_allowed = max(0, grant - used)
def _compute_number_card(self):
for record in self:
count = 0