# -*- coding: utf-8 -*- # Copyright 2026 Nexa Systems Inc. # License OPL-1 (Odoo Proprietary License v1.0) """Backfill schedule state on upgrade to 19.0.3.12.0. Before this version there was no draft/posted concept — every dated ``fusion.clock.schedule`` entry was authoritative and drove reminders, absence checks and penalties. The new ``state`` field defaults to 'draft', and the schedule resolver now only acts on POSTED entries. Without this backfill, every pre-existing schedule entry would silently become draft on upgrade and stop driving automation. Mark all pre-existing entries 'posted' to preserve prior behaviour. (Runs only on upgrade, never on a fresh install.) """ def migrate(cr, version): if not version: return cr.execute(""" UPDATE fusion_clock_schedule SET state = 'posted', posted_date = COALESCE(posted_date, now()) WHERE state IS NULL OR state = 'draft' """)