Skip to content

[19.0][MIG] hr_shift: Migration to 19.0#38

Open
XtremXpert wants to merge 23 commits into
OCA:19.0from
bemade:19.0-mig-hr_shift
Open

[19.0][MIG] hr_shift: Migration to 19.0#38
XtremXpert wants to merge 23 commits into
OCA:19.0from
bemade:19.0-mig-hr_shift

Conversation

@XtremXpert

@XtremXpert XtremXpert commented Jul 8, 2026

Copy link
Copy Markdown

Migration of hr_shift from 18.0 to 19.0, with commit history preserved via git format-patch.

Changes required by Odoo 19

  • resource.models.utils.string_to_datetime was removed → localize naive ORM datetimes with pytz.utc.localize directly
  • hr.employee.base was merged into hr.employee → inherit hr.employee
  • _sql_constraintsmodels.Constraint
  • res.groups: category_id/users replaced by privilege_id/user_ids, with a new res.groups.privilege record
  • Search views: <group> no longer accepts the string attribute
  • Search domains now require naive UTC datetimes
  • self._context deprecation → self.env.context
  • fields.datetime lowercase alias removed → datetime.combine
  • prefer-env-translation (pylint mandatory): self.env._() in methods; selection labels as plain strings (exported by the ORM)
  • no-search-all (pylint mandatory): inline disable on the two _group_expand methods — shift templates are a small bounded configuration table
  • Tests are now self-contained: demo data is no longer installed by default in Odoo 19, so the test fixtures (shift templates) are created in setUpClass instead of env.ref on demo records. The templates are created with tz=Europe/Brussels to preserve the original UTC assertions, and the test user gets a fallback timezone (required by _compute_shift_time). Tests pass both with and without demo data.

Notes for reviewers

  • Tests pass: 0 failed, 0 error(s) of 4 tests on a fresh 19.0 database, with and without --with-demo
  • hr_shift_holidays_public (present in 17.0) is not part of this PR since it was never migrated to 18.0.

🤖 Generated with Claude Code

chienandalu and others added 22 commits July 8, 2026 05:38
TT50623

Co-authored-by: chienandalu

[UPD] Update hr_shift.pot

[BOT] post-merge updates
Changes done:
- Add rules related to shift lines
- Add My shifts filter + group by fields
- Add template + employee fields to calendar view
- Set widget="many2one_avatar_employee" to employee_id field (tree view)
Co-authored-by: neitherkx <dpalancamartinez@gmail.com>
This module replaces theoretical calendar attendances by the shift ones
in a conservative way, only removing those that belong to the exact
shift. That way, if no shift is specified, the usual calendar will
apply.

But when the shift is at or around midnight, there can be 2 dates
involved, the starting day, and the ending day. If the calendar assigned
to the employee has attendance entries in both of them, the replacing
of them won't be correct.

Thus, we should remove all the attendances entries belonging to any of
the days of the shift, no matter the hours.

TT61053
- Replace removed resource.models.utils.string_to_datetime with
  pytz.utc.localize on naive ORM datetimes
- hr.employee.base was merged into hr.employee in Odoo 19
- Convert _sql_constraints to models.Constraint
- res.groups: category_id/users replaced by privilege_id/user_ids
  (new res.groups.privilege record)
- Search views: <group> no longer accepts the string attribute
- Use naive UTC datetimes in search domains (Odoo 19 requirement)
- Replace deprecated self._context with self.env.context
- fields.datetime alias removed: use datetime.combine directly
- prefer-env-translation: use self.env._() / plain selection labels
- Tests still require demo data (--with-demo, no longer the default)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@XtremXpert XtremXpert force-pushed the 19.0-mig-hr_shift branch from 3c76220 to 2577b42 Compare July 8, 2026 10:24
@pedrobaeza

Copy link
Copy Markdown
Member

/ocabot migration hr_shift

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.