This commit is contained in:
gsinghpal
2026-03-16 08:14:56 -04:00
parent fdca9518ab
commit e56974d46f
196 changed files with 19739 additions and 3471 deletions

View File

@@ -8,6 +8,7 @@ import logging
from datetime import datetime, timedelta
from odoo import http, fields, _
from odoo.http import request
from odoo.addons.fusion_clock.models.tz_utils import get_local_today, get_local_day_boundaries
_logger = logging.getLogger(__name__)
@@ -126,7 +127,7 @@ class FusionClockAPI(http.Controller):
'scheduled_time': scheduled_dt,
'actual_time': actual_dt,
'penalty_minutes': deduction,
'date': actual_dt.date() if isinstance(actual_dt, datetime) else fields.Date.today(),
'date': actual_dt.date() if isinstance(actual_dt, datetime) else get_local_today(request.env, employee),
})
# Deduct penalty minutes from attendance (adds to break deduction)
@@ -266,7 +267,7 @@ class FusionClockAPI(http.Controller):
)
now = fields.Datetime.now()
today = now.date()
today = get_local_today(request.env, employee)
geo_info = {
'latitude': latitude,
@@ -529,24 +530,23 @@ class FusionClockAPI(http.Controller):
'location_id': att.x_fclk_location_id.id or False,
})
today_start = fields.Datetime.to_string(
datetime.combine(fields.Date.today(), datetime.min.time())
)
local_today = get_local_today(request.env, employee)
today_start_utc, today_end_utc = get_local_day_boundaries(request.env, local_today, employee)
today_atts = request.env['hr.attendance'].sudo().search([
('employee_id', '=', employee.id),
('check_in', '>=', today_start),
('check_in', '>=', fields.Datetime.to_string(today_start_utc)),
('check_in', '<', fields.Datetime.to_string(today_end_utc)),
('check_out', '!=', False),
])
result['today_hours'] = round(sum(a.x_fclk_net_hours or 0 for a in today_atts), 2)
today = fields.Date.today()
today = get_local_today(request.env, employee)
week_start = today - timedelta(days=today.weekday())
week_start_dt = fields.Datetime.to_string(
datetime.combine(week_start, datetime.min.time())
)
week_start_utc, _ = get_local_day_boundaries(request.env, week_start, employee)
week_atts = request.env['hr.attendance'].sudo().search([
('employee_id', '=', employee.id),
('check_in', '>=', week_start_dt),
('check_in', '>=', fields.Datetime.to_string(week_start_utc)),
('check_in', '<', fields.Datetime.to_string(today_end_utc)),
('check_out', '!=', False),
])
result['week_hours'] = round(sum(a.x_fclk_net_hours or 0 for a in week_atts), 2)
@@ -614,8 +614,8 @@ class FusionClockAPI(http.Controller):
return {'error': 'Access denied.'}
now = fields.Datetime.now()
today = fields.Date.today()
today_start = datetime.combine(today, datetime.min.time())
today = get_local_today(request.env)
today_start, _ = get_local_day_boundaries(request.env, today)
Attendance = request.env['hr.attendance'].sudo()
Employee = request.env['hr.employee'].sudo()