-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.py
More file actions
43 lines (36 loc) · 1.53 KB
/
Copy pathinit.py
File metadata and controls
43 lines (36 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# 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`.
# Defaults changed from (700, 10, 10) to (2000, 10, 10) in 3.13
# and the last generation was removed in 3.14.
# ----------------------------------------------------------
if gc.get_threshold()[0] in (700, 2000):
# 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