# -*- coding: utf-8 -*- # Copyright 2026 Nexa Systems Inc. # License OPL-1 (Odoo Proprietary License v1.0) # Part of the Fusion Plating product family. import logging from . import controllers from . import models _logger = logging.getLogger(__name__) def post_init_hook(env): """Auto-detect a sensible default timezone on first install. Sets ``res.company.x_fc_default_tz`` to the admin user's timezone (Odoo populates that from the browser on first login), falling back to the host server's timezone, then to ``America/Toronto`` as a last resort. Only writes when the field is still empty so re-installs never clobber a user's choice. """ from .models.fp_tz import detect_default_tz detected = detect_default_tz(env) for company in env['res.company'].sudo().search([]): if not company.x_fc_default_tz: company.x_fc_default_tz = detected _logger.info( 'Fusion Plating: set default timezone for company %s -> %s', company.name, detected, )