Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] hr_attendance_missing_days: don't break on multi work day attendances #1

Conversation

hbrunn
Copy link

@hbrunn hbrunn commented Dec 23, 2023

@fkantelberg thanks again for this. We ran into an issue when an attendance spans multiple days in the work calendar, here my proposed fix plus test case.

While being on it, I took the liberty to add another commit adding a test for hr_attendance_contract_missing_days, hoping greenness will trigger the good people of hr-attendance maintainers to merge the PR.

@@ -79,6 +79,9 @@ def _create_missing_attendances(self, date_from=None, date_to=None):
attendances = {
ensure_tz(attendance.check_in, tz).date()
for attendance in self.attendance_ids.filtered_domain(domain)
} | {
ensure_tz(attendance.check_out, tz).date()
for attendance in self.attendance_ids.filtered_domain(domain)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered enumerating the days between check_in and check_out, but then I couldn't think of a real live case where anyone records 24+ hours

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically it's clean but the entire self.attendance_ids.filtered_domain(domain) would be executed multiple times. I guess the following could be better (well I'm not fully pleased with the naming)

attendances = self.attendance_ids.filtered_domain(domain)
attendances = attendances.mapped("check_in") + attendances.mapped("check_out")
attendances = {ensure_tz(attendance, tz).date() for attendance in attendances}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, made it so

@@ -79,6 +79,9 @@ def _create_missing_attendances(self, date_from=None, date_to=None):
attendances = {
ensure_tz(attendance.check_in, tz).date()
for attendance in self.attendance_ids.filtered_domain(domain)
} | {
ensure_tz(attendance.check_out, tz).date()
for attendance in self.attendance_ids.filtered_domain(domain)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically it's clean but the entire self.attendance_ids.filtered_domain(domain) would be executed multiple times. I guess the following could be better (well I'm not fully pleased with the naming)

attendances = self.attendance_ids.filtered_domain(domain)
attendances = attendances.mapped("check_in") + attendances.mapped("check_out")
attendances = {ensure_tz(attendance, tz).date() for attendance in attendances}

@fkantelberg fkantelberg merged commit 532f10f into initOS:15.0-hr_attendance_missing_days Jan 15, 2024
3 of 4 checks passed
fkantelberg pushed a commit that referenced this pull request Jan 15, 2024
…dances (#1)

* [IMP] hr_attendance_missing_days: don't break on multi work day attendances

* [ADD] hr_attendance_contract_missing_days: tests

* fixup! [ADD] hr_attendance_contract_missing_days: tests
ortlam pushed a commit that referenced this pull request May 28, 2024
…dances (#1)

* [IMP] hr_attendance_missing_days: don't break on multi work day attendances

* [ADD] hr_attendance_contract_missing_days: tests

* fixup! [ADD] hr_attendance_contract_missing_days: tests
ortlam pushed a commit that referenced this pull request Aug 14, 2024
…dances (#1)

* [IMP] hr_attendance_missing_days: don't break on multi work day attendances

* [ADD] hr_attendance_contract_missing_days: tests

* fixup! [ADD] hr_attendance_contract_missing_days: tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants