Compare commits
28 Commits
31bd225709
...
05d145c5cd
| Author | SHA1 | Date |
|---|---|---|
|
|
05d145c5cd | |
|
|
9c6feae512 | |
|
|
71293ad8ef | |
|
|
fc053eca72 | |
|
|
40020cf23c | |
|
|
edc151bb1e | |
|
|
2908134931 | |
|
|
212900a1d3 | |
|
|
bd382f6d20 | |
|
|
5f23d59213 | |
|
|
db1906ce4c | |
|
|
1befd50b28 | |
|
|
9c1ebc720c | |
|
|
b88c388b75 | |
|
|
52641f4514 | |
|
|
9b751e29d5 | |
|
|
a588370258 | |
|
|
2498d1010b | |
|
|
ab560ad6d6 | |
|
|
daf31782fd | |
|
|
f88623168f | |
|
|
0537dc1979 | |
|
|
e5972f0f92 | |
|
|
902813c978 | |
|
|
eb4ccbfa22 | |
|
|
01f5d4c74e | |
|
|
f07ae8eb99 | |
|
|
19bdf92f67 |
|
|
@ -18,8 +18,12 @@
|
|||
'version': '0.1',
|
||||
|
||||
# any module necessary for this one to work correctly
|
||||
|
||||
'depends': ['base','hr','account','mail','hr_skills', 'hr_contract'],
|
||||
|
||||
|
||||
|
||||
|
||||
# always loaded
|
||||
'data': [
|
||||
'security/security.xml',
|
||||
|
|
|
|||
|
|
@ -256,6 +256,8 @@ class HRJobRecruitment(models.Model):
|
|||
rec.submission_status = 'zero'
|
||||
|
||||
|
||||
experience = fields.Many2one('candidate.experience', string="Experience")
|
||||
|
||||
@api.depends('application_ids.submitted_to_client')
|
||||
def _compute_no_of_submissions(self):
|
||||
counts = dict(self.env['hr.applicant']._read_group(
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from odoo import models, fields, api
|
|||
from datetime import timedelta
|
||||
import json
|
||||
from collections import defaultdict
|
||||
from datetime import datetime
|
||||
from pytz import timezone, UTC
|
||||
|
||||
|
||||
class AttendanceWeeklyReport(models.Model):
|
||||
|
|
@ -22,32 +22,39 @@ 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
|
||||
date = att.check_in.date()
|
||||
grouped_attendance[emp][date].append(att)
|
||||
check_in_local = att.check_in.astimezone(tz)
|
||||
date_local = check_in_local.date()
|
||||
grouped_attendance[emp][date_local].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.time().strftime('%H:%M')
|
||||
first_in = records[0].check_in.astimezone(tz).strftime('%H:%M')
|
||||
last_out = 'N/A'
|
||||
|
||||
for rec in records:
|
||||
if rec.check_in and rec.check_out:
|
||||
total_seconds += (rec.check_out - rec.check_in).total_seconds()
|
||||
last_out = rec.check_out.time().strftime('%H:%M')
|
||||
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')
|
||||
|
||||
employee_data[emp_name].append({
|
||||
'date': date.strftime('%Y-%m-%d'),
|
||||
|
|
@ -55,7 +62,6 @@ 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;">
|
||||
|
|
|
|||
Loading…
Reference in New Issue