Skip to content

Commit

Permalink
[MIG] hr_attendance_missing_days: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HeliconiaSolutions committed Dec 19, 2024
1 parent dd1aa49 commit a268077
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 75 deletions.
3 changes: 2 additions & 1 deletion hr_attendance_missing_days/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Attendance generation for missing days
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:a7b271cc69f2b0c4434fc4c31c9f07dee7a0f881103f0ba56dce9bd0c5c2d46a
!! source digest: sha256:14140f914d671ae2a6dcb45632700b88906ccec2abe52643c512ac5de601207d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down Expand Up @@ -64,6 +64,7 @@ Contributors
------------

- initOS GmbH (initOS.com)
- `Heliconia Solutions Pvt. Ltd. <https://www.heliconia.io>`__

Maintainers
-----------
Expand Down
2 changes: 1 addition & 1 deletion hr_attendance_missing_days/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"name": "Attendance generation for missing days",
"version": "15.0.1.0.0",
"version": "17.0.1.0.0",
"category": "Hidden",
"author": "initOS GmbH, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/hr-attendance",
Expand Down
62 changes: 0 additions & 62 deletions hr_attendance_missing_days/i18n/hr_attendance_missing_days.pot

This file was deleted.

31 changes: 22 additions & 9 deletions hr_attendance_missing_days/models/hr_employee.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,22 @@ def _create_missing_attendances(self, date_from=None, date_to=None):
if not date_to:
date_to = date.today()

# Determine the start and end of the day and convert to UTC
dt_from = datetime.combine(date_from, time.min)
dt_to = datetime.combine(date_to, time.max)
# Ensure date_from and date_to are datetime objects, not just date objects
if isinstance(
date_from, date
): # If date_from is a date object, convert it to datetime
date_from = datetime.combine(date_from, time.min)
if isinstance(
date_to, date
): # If date_to is a date object, convert it to datetime
date_to = datetime.combine(date_to, time.max)

tz = pytz.timezone(self.tz or "UTC")
dt_from, dt_to = map(tz.localize, (dt_from, dt_to))

# Now they are datetime objects, we can safely localize them
dt_from, dt_to = map(tz.localize, (date_from, date_to))

# Ensure the time zone is set to UTC
dt_from, dt_to = ensure_tz(dt_from, pytz.utc), ensure_tz(dt_to, pytz.utc)

# Skip the active day
Expand All @@ -77,11 +87,14 @@ def _create_missing_attendances(self, date_from=None, date_to=None):
("check_in", "<=", dt_to.replace(tzinfo=None)),
]
attendance_records = self.attendance_ids.filtered_domain(domain)
attendances = {
ensure_tz(attendance_date, tz).date()
for attendance_date in attendance_records.mapped("check_in")
+ attendance_records.mapped("check_out")
}

attendances = set()
for attendance_date in attendance_records.mapped("check_in"):
if attendance_date:
attendances.add(ensure_tz(attendance_date, tz).date())
for attendance_date in attendance_records.mapped("check_out"):
if attendance_date: # Handle empty check_out field
attendances.add(ensure_tz(attendance_date, tz).date())

vals = []
for missing in set(work_dates) - attendances:
Expand Down
1 change: 1 addition & 0 deletions hr_attendance_missing_days/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- initOS GmbH (initOS.com)
- [Heliconia Solutions Pvt. Ltd.](https://www.heliconia.io)
Binary file not shown.
3 changes: 2 additions & 1 deletion hr_attendance_missing_days/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Attendance generation for missing days</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:a7b271cc69f2b0c4434fc4c31c9f07dee7a0f881103f0ba56dce9bd0c5c2d46a
!! source digest: sha256:14140f914d671ae2a6dcb45632700b88906ccec2abe52643c512ac5de601207d
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/hr-attendance/tree/17.0/hr_attendance_missing_days"><img alt="OCA/hr-attendance" src="https://img.shields.io/badge/github-OCA%2Fhr--attendance-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/hr-attendance-17-0/hr-attendance-17-0-hr_attendance_missing_days"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/hr-attendance&amp;target_branch=17.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This modules generates attendances for employee with 0 minutes for
Expand Down Expand Up @@ -411,6 +411,7 @@ <h2><a class="toc-backref" href="#toc-entry-3">Authors</a></h2>
<h2><a class="toc-backref" href="#toc-entry-4">Contributors</a></h2>
<ul class="simple">
<li>initOS GmbH (initOS.com)</li>
<li><a class="reference external" href="https://www.heliconia.io">Heliconia Solutions Pvt. Ltd.</a></li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="hr_attendance.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@data-key='hr_attendance']" position="inside">
<xpath expr="//app[@name='hr_attendance']" position="inside">
<h2>Missing Attendance</h2>
<div
class="row mt16 o_settings_container"
Expand Down

0 comments on commit a268077

Please sign in to comment.