# -*- coding: utf-8 -*-
from . import models

from odoo import api, SUPERUSER_ID

def post_init_hook(*args, **kwargs):
    """
    Setup IAP account after module installation.
    Flexible signature to avoid TypeError on different Odoo versions.
    """
    # Try to get env from args, otherwise fallback to cr/registry logic
    if args and isinstance(args[0], api.Environment):
        env = args[0]
    elif len(args) >= 2:
        cr, registry = args[0], args[1]
        env = api.Environment(cr, SUPERUSER_ID, {})
    else:
        # Fallback if called weirdly
        return True
        
    env['iap.account'].search_or_create_ocr_account()
