fix(fusion_clock): stop stale missed-clock-in nag; add Owner role + attendance exemption
The "explain your missed clock-out" dialog (driven by hr.employee. x_fclk_pending_reason) was set by the absence + auto-clock-out crons but only cleared by the systray reason dialog -- never by the kiosk/NFC clock paths that staff actually use. During the kiosk rollout the absence cron flagged the whole company (hundreds of "absent" logs); those stale flags then nagged everyone forever, even while currently clocked in. Fixes: - Clear x_fclk_pending_reason on every successful clock-in (portal, systray, PIN kiosk, NFC kiosk). Back on the clock => no nag. - get_status / dashboard never report pending while checked-in or exempt; the systray also guards the dialog client-side. - Absence detection no longer sets x_fclk_pending_reason (an absence has no "departure time" to explain). It still logs 'absent' + notifies the office. - One-time migration (19.0.4.2.0) clears existing stale flags. Owner / attendance exemption: - New "Owner" role (top of the Fusion Clock access dropdown, implies Manager) plus a per-employee "Exempt from Attendance" checkbox. - hr.employee._fclk_is_attendance_exempt(); the absence, auto-clock-out, reminder and weekly-summary crons all skip exempt employees, and the dialog is suppressed for them. Tests: tests/test_pending_reason_exempt.py (13 cases). Full fusion_clock suite green except pre-existing env-sensitive failures. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -345,6 +345,9 @@ class HrAttendance(models.Model):
|
||||
continue
|
||||
|
||||
employee = att.employee_id
|
||||
# Owners / attendance-exempt employees are never auto-clocked-out or nagged.
|
||||
if employee._fclk_is_attendance_exempt():
|
||||
continue
|
||||
clock_out_time = effective_deadline
|
||||
try:
|
||||
with self.env.cr.savepoint():
|
||||
@@ -456,6 +459,9 @@ class HrAttendance(models.Model):
|
||||
for emp in employees:
|
||||
try:
|
||||
with self.env.cr.savepoint():
|
||||
# Owners / attendance-exempt employees are never flagged absent.
|
||||
if emp._fclk_is_attendance_exempt():
|
||||
continue
|
||||
yesterday = get_local_today(self.env, emp) - timedelta(days=1)
|
||||
|
||||
# Only days the employee was actually scheduled to work
|
||||
@@ -498,7 +504,11 @@ class HrAttendance(models.Model):
|
||||
'source': 'system',
|
||||
})
|
||||
|
||||
emp.sudo().write({'x_fclk_pending_reason': True})
|
||||
# NOTE: an absence does NOT set x_fclk_pending_reason. That flag
|
||||
# drives the "explain your missed clock-OUT (departure time)"
|
||||
# dialog, which is meaningless for a day with no attendance and
|
||||
# caused a persistent false nag. The absence is logged + the
|
||||
# office is notified on excess; that is the absence remedy.
|
||||
|
||||
month_start = yesterday.replace(day=1)
|
||||
month_boundary_start, _ = get_local_day_boundaries(self.env, month_start, emp)
|
||||
@@ -546,6 +556,9 @@ class HrAttendance(models.Model):
|
||||
for emp in employees:
|
||||
try:
|
||||
with self.env.cr.savepoint():
|
||||
# Owners / attendance-exempt employees are never reminded.
|
||||
if emp._fclk_is_attendance_exempt():
|
||||
continue
|
||||
today = get_local_today(self.env, emp)
|
||||
if not emp._get_fclk_day_plan(today).get('scheduled'):
|
||||
continue
|
||||
@@ -610,6 +623,9 @@ class HrAttendance(models.Model):
|
||||
company_name = company.name or ''
|
||||
|
||||
for emp in employees:
|
||||
# Owners / attendance-exempt employees get no weekly summary.
|
||||
if emp._fclk_is_attendance_exempt():
|
||||
continue
|
||||
if not emp.work_email:
|
||||
continue
|
||||
|
||||
|
||||
Reference in New Issue
Block a user