Skip to content

[18.0][FIX] hr_shift: current_shift_id must be the shift active right now - #44

Merged
OCA-git-bot merged 1 commit into
OCA:18.0from
invitu:18.0-fix_hr_shift_employee_current_shift
Aug 24, 2026
Merged

[18.0][FIX] hr_shift: current_shift_id must be the shift active right now#44
OCA-git-bot merged 1 commit into
OCA:18.0from
invitu:18.0-fix_hr_shift_employee_current_shift

Conversation

@cvinh

@cvinh cvinh commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

The compute filled current_shift_id with any shift scheduled today using a UTC-day window. In non-UTC timezones (GMT-10), the day boundary splits across two UTC days and same-day shifts can raise a SingletonError on the Many2one assignment.

Switch _shift_of_date's domain from containment to overlap and call it with (now, now) so the field matches the shift covering this instant, as its name implies. Night shifts crossing midnight are covered as a side effect. _shift_of_date is kept as a public hook.

Comment thread hr_shift/models/hr_employee.py
@cvinh
cvinh force-pushed the 18.0-fix_hr_shift_employee_current_shift branch from f1877c2 to 84d527c Compare August 21, 2026 09:13

@Abranes Abranes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@pedrobaeza pedrobaeza added this to the 18.0 milestone Aug 23, 2026
@pedrobaeza
pedrobaeza requested a review from victoralmau August 23, 2026 10:16
Comment thread hr_shift/tests/test_hr_shift.py Outdated
The compute filled current_shift_id with any shift scheduled today
using a UTC-day window. In non-UTC timezones (GMT-10), the day
boundary splits across two UTC days and same-day shifts can raise
a SingletonError on the Many2one assignment.

Switch _shift_of_date's domain from containment to overlap and
call it with (now, now) so the field matches the shift covering
this instant, as its name implies. Night shifts crossing midnight
are covered as a side effect. _shift_of_date is kept as a public
hook.

Assisted-by: Claude Opus 4.7
@cvinh
cvinh force-pushed the 18.0-fix_hr_shift_employee_current_shift branch from 84d527c to 4724c60 Compare August 24, 2026 07:37
@pedrobaeza

Copy link
Copy Markdown
Member

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 18.0-ocabot-merge-pr-44-by-pedrobaeza-bump-patch, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit 424b207 into OCA:18.0 Aug 24, 2026
7 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at c7fe467. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants