Coverage for adhoc-cicd-odoo-odoo / odoo / init.py: 95%
18 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-09 18:05 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-09 18:05 +0000
1# ruff: noqa: E402, F401
2# Part of Odoo. See LICENSE file for full copyright and licensing details.
4""" Odoo initialization. """
6import gc
7import sys
8from .release import MIN_PY_VERSION
9assert sys.version_info > MIN_PY_VERSION, f"Outdated python version detected, Odoo requires Python >= {'.'.join(map(str, MIN_PY_VERSION))} to run."
11# ----------------------------------------------------------
12# Set gc thresolds if they are default, see `odoo.tools.gc`.
13# Defaults changed from (700, 10, 10) to (2000, 10, 10) in 3.13
14# and the last generation was removed in 3.14.
15# ----------------------------------------------------------
16if gc.get_threshold()[0] in (700, 2000): 16 ↛ 25line 16 didn't jump to line 25 because the condition on line 16 was always true
17 # Handling requests can sometimes allocate over 5k new objects, let leave
18 # some space before starting any collection.
19 gc.set_threshold(12_000, 20, 25)
21# ----------------------------------------------------------
22# Import tools to patch code and libraries
23# required to do as early as possible for evented and timezone
24# ----------------------------------------------------------
25from . import _monkeypatches
26_monkeypatches.patch_init()
28from .tools.gc import gc_set_timing
29gc_set_timing(enable=True)
31# ----------------------------------------------------------
32# Shortcuts
33# Expose them at the `odoo` namespace level
34# ----------------------------------------------------------
35import odoo
36from .orm.commands import Command
37from .orm.utils import SUPERUSER_ID
38from .tools.translate import _, _lt
40odoo.SUPERUSER_ID = SUPERUSER_ID
41odoo._ = _
42odoo._lt = _lt
43odoo.Command = Command