feat(fusion_clock): schedule parity — overnight, split shifts, open shifts [B1-B3]

is_open + crosses_midnight fields; employee_id optional (open shifts);
company_id computed w/ env.company fallback; drop hard one-per-day UNIQUE
(allow split + open). Overnight math in planned_hours/_check_schedule_times/
scheduled_times. _get_fclk_day_plan resolves multiple posted rows into ONE
work-window so penalties/overtime/absence stay correct. Migration drops the
old constraint defensively. Tests for overnight, window, open shifts.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsinghpal
2026-06-04 21:04:58 -04:00
parent d35d5f4b34
commit 68aaa132ee
6 changed files with 252 additions and 23 deletions

View File

@@ -24,6 +24,14 @@ def migrate(cr, version):
lives in fusion.clock.schedule._fclk_port_planning_data so it can be unit
tested on an Enterprise clone where planning is installed."""
env = api.Environment(cr, SUPERUSER_ID, {})
# Phase B drops the hard one-shift-per-day uniqueness so split/open shifts
# are allowed. Odoo drops removed declarative constraints on upgrade, but be
# explicit so the upgrade can never leave the old constraint behind.
cr.execute(
"ALTER TABLE fusion_clock_schedule "
"DROP CONSTRAINT IF EXISTS fusion_clock_schedule_employee_date_unique")
ICP = env['ir.config_parameter'].sudo()
if ICP.get_param(_MARKER):
_logger.info("Fusion Clock: planning data already migrated; skipping.")