Compare commits

..

35 Commits

Author SHA1 Message Date
administrator ce96c95fa1 Merge branch 'develop' 2025-06-02 15:50:09 +05:30
administrator 31bd225709 Merge branch 'feature/odoo18' into develop 2025-06-02 15:47:39 +05:30
administrator 534667672a ignore 2025-06-02 15:44:54 +05:30
administrator 24c6b24790 Merge branch 'develop' 2025-06-02 15:22:50 +05:30
administrator 92238324f4 Merge branch 'feature/odoo18' into develop 2025-06-02 15:21:20 +05:30
administrator cc34d58bdb pull commit 2025-06-02 15:19:52 +05:30
administrator 0546a107ec Merge branch 'develop' 2025-05-30 18:21:32 +05:30
administrator ad3dc6f437 Merge branch 'feature/odoo18' into develop 2025-05-30 18:20:46 +05:30
administrator a9f0c83e35 001-1
Merge branch 'develop'
2025-05-23 12:25:26 +05:30
administrator 0c85321c96 Initial commit 2025-05-23 12:22:39 +05:30
Pranay 51dc506d6e TimeOff Fix 2025-05-23 12:21:26 +05:30
Pranay 461f084eb4 time-off FIX 2025-05-23 12:21:26 +05:30
Pranay b545ef81a9 Recruitment Changes 2025-05-23 12:19:54 +05:30
Pranay 83167be407 fix whatsapp 2025-05-23 12:19:54 +05:30
Pranay 4b3afff56b update whatsapp code 2025-05-23 12:19:54 +05:30
administrator dbc30fa855 Initial commit 2025-05-23 12:19:53 +05:30
administrator 8686f0ecf1 Initial commit 2025-05-23 12:19:53 +05:30
administrator d94dfd962f Initial commit 2025-05-23 12:19:53 +05:30
administrator 69e66a9065 Initial commit 2025-05-23 12:19:53 +05:30
administrator 394677fe17 Initial commit 2025-05-23 12:16:19 +05:30
administrator acb7d38f2a Initial commit 2025-05-23 12:16:19 +05:30
administrator d7971d6414 Initial commit 2025-05-23 12:16:19 +05:30
administrator 6053a58c41 Initial commit 2025-05-23 12:16:19 +05:30
administrator bdb85bbd94 Initial commit 2025-05-23 12:16:19 +05:30
administrator 46258a8a3b Initial commit 2025-05-23 12:16:19 +05:30
administrator 8ee861083a Initial commit 2025-05-23 12:16:19 +05:30
administrator be903c6781 Initial commit 2025-05-23 12:16:19 +05:30
administrator 993d87bfc7 Initial commit 2025-05-23 12:16:19 +05:30
administrator 0149fb19cc Initial commit 2025-05-23 12:16:19 +05:30
administrator 8d5189a3c3 Initial commit 2025-05-23 12:16:19 +05:30
administrator 138408fdcc Initial commit 2025-05-23 12:16:19 +05:30
administrator e7bb5030e7 Initial commit 2025-05-23 12:16:19 +05:30
administrator 4764cc2c35 Initial commit 2025-05-23 12:16:19 +05:30
administrator 6f7dbe6c26 Initial commit 2025-05-23 12:16:19 +05:30
administrator aa74698885 Initial commit 2025-05-23 12:16:19 +05:30
1 changed files with 9 additions and 15 deletions

View File

@ -2,7 +2,7 @@ from odoo import models, fields, api
from datetime import timedelta
import json
from collections import defaultdict
from pytz import timezone, UTC
from datetime import datetime
class AttendanceWeeklyReport(models.Model):
@ -22,39 +22,32 @@ class AttendanceWeeklyReport(models.Model):
last_monday = today - timedelta(days=today.weekday() + 7)
last_sunday = last_monday + timedelta(days=6)
user_tz = self.env.user.tz or 'UTC'
tz = timezone(user_tz)
# Search for attendance in UTC (Odoo stores in UTC)
attendances = self.env['hr.attendance'].search([
('check_in', '>=', str(last_monday)),
('check_out', '<=', str(last_sunday + timedelta(days=1)))
])
employee_data = {}
employee_data = defaultdict(list)
grouped_attendance = defaultdict(lambda: defaultdict(list)) # {emp: {date: [attendances]}}
# Group attendances by employee and local date
for att in attendances:
emp = att.employee_id.name
check_in_local = att.check_in.astimezone(tz)
date_local = check_in_local.date()
grouped_attendance[emp][date_local].append(att)
date = att.check_in.date()
grouped_attendance[emp][date].append(att)
# Process each employee's attendance
for emp_name, dates in grouped_attendance.items():
for date, records in dates.items():
records = sorted(records, key=lambda a: a.check_in)
total_seconds = 0
first_in = records[0].check_in.astimezone(tz).strftime('%H:%M')
first_in = records[0].check_in.time().strftime('%H:%M')
last_out = 'N/A'
for rec in records:
if rec.check_in and rec.check_out:
check_in_local = rec.check_in.astimezone(tz)
check_out_local = rec.check_out.astimezone(tz)
total_seconds += (check_out_local - check_in_local).total_seconds()
last_out = check_out_local.strftime('%H:%M')
total_seconds += (rec.check_out - rec.check_in).total_seconds()
last_out = rec.check_out.time().strftime('%H:%M')
employee_data[emp_name].append({
'date': date.strftime('%Y-%m-%d'),
@ -62,6 +55,7 @@ class AttendanceWeeklyReport(models.Model):
'out': last_out,
'hours': f'{total_seconds / 3600:.2f}',
})
# Inline QWeb-compatible HTML template (must be in a real view in production)
html_template = """
<div style="max-width:800px;margin:auto;background-color:#fff;padding:20px;border:1px solid #ddd;border-radius:8px;">