changes
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user