考勤确认单跳转

This commit is contained in:
李鹏宇
2026-03-04 11:28:49 +08:00
parent 120d1f2321
commit dbbbfa4455
2 changed files with 42 additions and 2 deletions
@@ -669,6 +669,44 @@ class YuthonVacationReports(models.Model):
f"已存在假期额度记录,不能重复创建!"
)
def action_prev_month(self):
"""跳转到上一个月的假期记录"""
self.ensure_one()
prev_date = (self.vacation_date - relativedelta(months=1)).replace(day=1)
prev_record = self.search([
('employee_id', '=', self.employee_id.id),
('vacation_date', '=', prev_date),
], limit=1)
if not prev_record:
raise UserError('上一个月没有对应的假期记录')
action = self.env['ir.actions.actions']._for_xml_id('yuthon_hr_attendance.view_yuthon_vacation_reports_action')
action.update({
'res_id': prev_record.id,
'views': [(False, 'form')],
'view_mode': 'form',
'target': 'current',
})
return action
def action_next_month(self):
"""跳转到下一个月的假期记录"""
self.ensure_one()
next_date = (self.vacation_date + relativedelta(months=1)).replace(day=1)
next_record = self.search([
('employee_id', '=', self.employee_id.id),
('vacation_date', '=', next_date),
], limit=1)
if not next_record:
raise UserError('下一个月没有对应的假期记录')
action = self.env['ir.actions.actions']._for_xml_id('yuthon_hr_attendance.view_yuthon_vacation_reports_action')
action.update({
'res_id': next_record.id,
'views': [(False, 'form')],
'view_mode': 'form',
'target': 'current',
})
return action
def action_open(self):
self.ensure_one()
target_date = self.vacation_date.replace(day=1)
@@ -180,10 +180,12 @@
</group>
<field name="employee_id" readonly="1"/>
<field name="vacation_date" readonly="1"/>
<div class="col-12 text-center">
<h1>
<div class="col-12 text-center d-flex align-items-center justify-content-center gap-2">
<button name="action_prev_month" type="object" string="&#9664;" class="btn btn-secondary"/>
<h1 class="mb-0">
<field name="display_date"/>
</h1>
<button name="action_next_month" type="object" string="&#9654;" class="btn btn-secondary"/>
</div>
<group col="4">
<group>