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

@@ -9,6 +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
_logger = logging.getLogger(__name__)
@@ -48,7 +49,7 @@ class FusionClockPortal(CustomerPortal):
if 'clock_count' in counters:
employee = self._get_portal_employee()
if employee:
today_start = datetime.combine(fields.Date.today(), datetime.min.time())
today_start, _ = get_local_day_boundaries(request.env, get_local_today(request.env, employee), employee)
count = request.env['hr.attendance'].sudo().search_count([
('employee_id', '=', employee.id),
('check_in', '>=', today_start),
@@ -99,7 +100,7 @@ class FusionClockPortal(CustomerPortal):
], limit=1)
# Today stats
today_start = datetime.combine(fields.Date.today(), datetime.min.time())
today_start, _ = get_local_day_boundaries(request.env, get_local_today(request.env, employee), employee)
today_atts = request.env['hr.attendance'].sudo().search([
('employee_id', '=', employee.id),
('check_in', '>=', today_start),
@@ -108,9 +109,9 @@ class FusionClockPortal(CustomerPortal):
today_hours = sum(a.x_fclk_net_hours or 0 for a in today_atts)
# Week stats
today = fields.Date.today()
today = get_local_today(request.env, employee)
week_start = today - timedelta(days=today.weekday())
week_start_dt = datetime.combine(week_start, datetime.min.time())
week_start_dt, _ = 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),
@@ -164,7 +165,7 @@ class FusionClockPortal(CustomerPortal):
schedule_type = ICP.get_param('fusion_clock.pay_period_type', 'biweekly')
period_start_str = ICP.get_param('fusion_clock.pay_period_start', '')
today = fields.Date.today()
today = get_local_today(request.env, employee)
# Calculate period dates
FusionReport = request.env['fusion.clock.report'].sudo()
@@ -190,10 +191,12 @@ class FusionClockPortal(CustomerPortal):
period_end -= timedelta(days=14)
# Get attendance records
period_start_utc, _ = get_local_day_boundaries(request.env, period_start, employee)
_, period_end_utc = get_local_day_boundaries(request.env, period_end, employee)
attendances = request.env['hr.attendance'].sudo().search([
('employee_id', '=', employee.id),
('check_in', '>=', datetime.combine(period_start, datetime.min.time())),
('check_in', '<', datetime.combine(period_end + timedelta(days=1), datetime.min.time())),
('check_in', '>=', period_start_utc),
('check_in', '<', period_end_utc),
], order='check_in desc')
total_hours = sum(a.worked_hours or 0 for a in attendances if a.check_out)