This commit is contained in:
gsinghpal
2026-03-17 13:32:08 -04:00
parent e56974d46f
commit 595dccc17d
11 changed files with 159 additions and 28 deletions

View File

@@ -343,6 +343,7 @@ class FusionClockAPI(http.Controller):
'attendance_id': attendance.id,
'check_in': fields.Datetime.to_string(attendance.check_in),
'location_name': location.name,
'location_address': location.address or '',
'message': f'Clocked in at {location.name}',
'streak': employee.x_fclk_ontime_streak,
}
@@ -389,6 +390,7 @@ class FusionClockAPI(http.Controller):
'break_minutes': attendance.x_fclk_break_minutes,
'overtime_hours': round(attendance.x_fclk_overtime_hours or 0, 2),
'location_name': location.name,
'location_address': location.address or '',
'message': f'Clocked out from {location.name}',
}
@@ -527,6 +529,7 @@ class FusionClockAPI(http.Controller):
'attendance_id': att.id,
'check_in': fields.Datetime.to_string(att.check_in),
'location_name': att.x_fclk_location_id.name or '',
'location_address': att.x_fclk_location_id.address or '',
'location_id': att.x_fclk_location_id.id or False,
})

View File

@@ -9,7 +9,7 @@ from datetime import datetime, timedelta
from odoo import http, fields, _
from odoo.http import request
from odoo.addons.portal.controllers.portal import CustomerPortal
from odoo.addons.fusion_clock.models.tz_utils import get_local_today, get_local_day_boundaries
from odoo.addons.fusion_clock.models.tz_utils import get_local_today, get_local_day_boundaries, utc_to_local_str
_logger = logging.getLogger(__name__)
@@ -119,11 +119,20 @@ class FusionClockPortal(CustomerPortal):
])
week_hours = sum(a.x_fclk_net_hours or 0 for a in week_atts)
# Recent activity
recent = request.env['hr.attendance'].sudo().search([
# Recent activity with local-timezone formatted times
recent_raw = request.env['hr.attendance'].sudo().search([
('employee_id', '=', employee.id),
('check_out', '!=', False),
], order='check_in desc', limit=10)
recent = []
for att in recent_raw:
recent.append({
'att': att,
'day_name': utc_to_local_str(att.check_in, request.env, employee, '%a'),
'day_num': utc_to_local_str(att.check_in, request.env, employee, '%d'),
'time_in': utc_to_local_str(att.check_in, request.env, employee, '%I:%M %p'),
'time_out': utc_to_local_str(att.check_out, request.env, employee, '%I:%M %p') if att.check_out else '--',
})
# Prepare locations JSON for JS
locations_json = json.dumps([{
@@ -203,9 +212,19 @@ class FusionClockPortal(CustomerPortal):
net_hours = sum(a.x_fclk_net_hours or 0 for a in attendances if a.check_out)
total_breaks = sum(a.x_fclk_break_minutes or 0 for a in attendances if a.check_out)
ts_attendances = []
for att in attendances:
ts_attendances.append({
'att': att,
'day_name': utc_to_local_str(att.check_in, request.env, employee, '%a'),
'day_date': utc_to_local_str(att.check_in, request.env, employee, '%b %d'),
'time_in': utc_to_local_str(att.check_in, request.env, employee, '%I:%M %p'),
'time_out': utc_to_local_str(att.check_out, request.env, employee, '%I:%M %p') if att.check_out else '',
})
values = {
'employee': employee,
'attendances': attendances,
'attendances': ts_attendances,
'period_start': period_start,
'period_end': period_end,
'period': period,