# -*- coding: utf-8 -*-
import logging

from . import models

_logger = logging.getLogger(__name__)


def post_init_hook(env):
    """Land internal users on the branded NACEF home dashboard instead of the
    Discuss inbox."""
    action = env.ref("nacef_cockpit.action_nacef_company_home",
                     raise_if_not_found=False)
    if not action:
        _logger.warning("NACEF cockpit: home action missing; landing unchanged.")
        return
    users = env["res.users"].search([("share", "=", False)])
    users.write({"action_id": action.id})
    _logger.info("NACEF cockpit: home dashboard set for %s user(s).", len(users))
