oca-ocb-core/odoo-bringout-oca-ocb-base/odoo/init.py
Ernad Husremovic 991d2234ca 19.0 vanilla
2025-10-03 18:07:25 +02:00

41 lines
1.4 KiB
Python

# ruff: noqa: E402, F401
# Part of Odoo. See LICENSE file for full copyright and licensing details.
""" Odoo initialization. """
import gc
import sys
from .release import MIN_PY_VERSION
assert sys.version_info > MIN_PY_VERSION, f"Outdated python version detected, Odoo requires Python >= {'.'.join(map(str, MIN_PY_VERSION))} to run."
# ----------------------------------------------------------
# Set gc thresolds if they are default, see `odoo.tools.gc`.
# ----------------------------------------------------------
if gc.get_threshold()[0] == 700:
# Handling requests can sometimes allocate over 5k new objects, let leave
# some space before starting any collection.
gc.set_threshold(12_000, 20, 25)
# ----------------------------------------------------------
# Import tools to patch code and libraries
# required to do as early as possible for evented and timezone
# ----------------------------------------------------------
from . import _monkeypatches
_monkeypatches.patch_init()
from .tools.gc import gc_set_timing
gc_set_timing(enable=True)
# ----------------------------------------------------------
# Shortcuts
# Expose them at the `odoo` namespace level
# ----------------------------------------------------------
import odoo
from .orm.commands import Command
from .orm.utils import SUPERUSER_ID
from .tools.translate import _, _lt
odoo.SUPERUSER_ID = SUPERUSER_ID
odoo._ = _
odoo._lt = _lt
odoo.Command = Command