51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
import logging
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
def post_init_hook(env):
|
|
"""Imperative one-shot operations after module data is loaded.
|
|
|
|
Each helper is idempotent — safe to re-run on -u.
|
|
"""
|
|
_logger.info("nexa_coa_setup: post_init_hook starting")
|
|
_normalize_company_hst_number(env)
|
|
_archive_unused_l10n_ca_accounts(env)
|
|
_rename_legacy_accounts(env)
|
|
_lock_fiscal_year_2025(env)
|
|
_logger.info("nexa_coa_setup: post_init_hook complete")
|
|
|
|
|
|
def _normalize_company_hst_number(env):
|
|
"""Convert '741224877' to '741224877 RT0001' if not already in full form."""
|
|
company = env.ref("base.main_company", raise_if_not_found=False)
|
|
if not company:
|
|
return
|
|
vat = (company.partner_id.vat or "").strip()
|
|
if vat == "741224877":
|
|
company.partner_id.vat = "741224877 RT0001"
|
|
_logger.info("nexa_coa_setup: normalized HST# to '741224877 RT0001'")
|
|
|
|
|
|
def _archive_unused_l10n_ca_accounts(env):
|
|
"""Stub — filled in Phase 4. Archives ~370 unused accounts."""
|
|
pass
|
|
|
|
|
|
def _rename_legacy_accounts(env):
|
|
"""Stub — filled in Phase 4. Renames the 14xx/15xx legacy accounts."""
|
|
pass
|
|
|
|
|
|
def _lock_fiscal_year_2025(env):
|
|
"""Set fiscalyear_lock_date = 2025-12-31 on main company."""
|
|
from datetime import date
|
|
company = env.ref("base.main_company", raise_if_not_found=False)
|
|
if not company:
|
|
return
|
|
target = date(2025, 12, 31)
|
|
if not company.fiscalyear_lock_date or company.fiscalyear_lock_date < target:
|
|
company.fiscalyear_lock_date = target
|
|
_logger.info("nexa_coa_setup: fiscalyear_lock_date set to 2025-12-31")
|