# -*- coding: utf-8 -*- """Phase H: fire role-migration preview creation on `-u fusion_plating`. Odoo 19's `post_init_hook` ONLY fires on fresh install — never on upgrade. So on entech (and any other already-installed deployment), `-u fusion_plating` after this branch lands would otherwise leave the post_init_hook's `_fp_post_init_role_migration` un-fired and the migration preview never created. This migration script bridges that gap: on every `-u` that crosses this version boundary, it invokes the same idempotent helper. The helper short-circuits if a preview is already pending or already applied + all users migrated, so re-running is safe. """ import logging _logger = logging.getLogger(__name__) def migrate(cr, version): from odoo import api, SUPERUSER_ID env = api.Environment(cr, SUPERUSER_ID, {}) try: from odoo.addons.fusion_plating import _fp_post_init_role_migration _fp_post_init_role_migration(env) _logger.info( 'Fusion Plating: role-migration preview check ran via post-migrate.py' ) except Exception as e: # Migration scripts must not block module upgrade — log and swallow _logger.exception( 'Failed to run role-migration preview check (non-fatal): %s', e )