diff --git a/odoo-stubs/modules/loading.pyi b/odoo-stubs/modules/loading.pyi index a05e06d..9e91be4 100644 --- a/odoo-stubs/modules/loading.pyi +++ b/odoo-stubs/modules/loading.pyi @@ -2,7 +2,7 @@ from typing import Any, Iterable from .graph import Graph, Node from .registry import Registry -from ..sql_db import Cursor +from ..sql_db import Cursor, Connection from ..tools.assertion_report import assertion_report def load_data(cr: Cursor, idref: dict, mode: str, kind: str, package: Node, report: assertion_report) -> bool: ... @@ -13,5 +13,5 @@ def load_module_graph(cr: Cursor, graph: Graph, status: Any | None = ..., perfor def _check_module_names(cr: Cursor, module_names: Iterable[str]) -> None: ... def load_marked_modules(cr: Cursor, graph: Graph, states: list[str], force: list[str], progressdict, report: assertion_report, loaded_modules: list[str], perform_checks: Any, models_to_check: set[str] | None = ...) -> list[str]: ... -def load_modules(db: Registry, force_demo: bool = ..., status: Any | None = ..., update_module: Any = ...) -> Registry | None: ... +def load_modules(db: Connection, force_demo: bool = ..., status: Any | None = ..., update_module: Any = ...) -> Registry | None: ... def reset_modules_state(db_name: str) -> None: ... diff --git a/odoo-stubs/modules/registry.pyi b/odoo-stubs/modules/registry.pyi index e58df20..98ac2db 100644 --- a/odoo-stubs/modules/registry.pyi +++ b/odoo-stubs/modules/registry.pyi @@ -1,71 +1,84 @@ -from collections import Mapping -from typing import Any, Optional +import threading +from collections import defaultdict, deque +from collections.abc import Mapping +from threading import RLock +from typing import Any, Callable, ClassVar, Iterable, Iterator +from weakref import WeakValueDictionary -from ..sql_db import Cursor +from .graph import Node +from ..models import BaseModel +from ..sql_db import Connection, Cursor +from ..tools.assertion_report import assertion_report +from ..tools.lru import LRU -_logger: Any -_schema: Any - -class Registry(Mapping): - _lock: Any = ... - _saved_lock: Any = ... - model_cache: Any = ... - def registries(cls): ... - def __new__(cls, db_name: Any): ... +class Registry(Mapping[str, type[BaseModel]]): + _lock: RLock + _saved_lock: RLock | None + model_cache: WeakValueDictionary + registries: ClassVar[LRU] + def __new__(cls, db_name: str) -> Registry: ... @classmethod - def new(cls, db_name: Any, force_demo: bool = ..., status: Optional[Any] = ..., update_module: bool = ...): ... - models: Any = ... - _sql_constraints: Any = ... - _init: bool = ... - _assertion_report: Any = ... - _fields_by_model: Any = ... - _post_init_queue: Any = ... - _constraint_queue: Any = ... - _init_modules: Any = ... - updated_modules: Any = ... - loaded_xmlids: Any = ... - db_name: Any = ... - _db: Any = ... - test_cr: Any = ... - test_lock: Any = ... - loaded: bool = ... - ready: bool = ... - registry_sequence: Any = ... - cache_sequence: Any = ... - registry_invalidated: bool = ... - cache_invalidated: bool = ... - has_unaccent: Any = ... - def init(self, db_name: Any) -> None: ... + def new(cls, db_name: str, force_demo: bool = ..., status: Any | None = ..., update_module: bool = ...) -> Registry: ... + models: dict[str, type[BaseModel]] + _sql_constraints: set + _init: bool + _assertion_report: assertion_report + _fields_by_model: Any + _post_init_queue: deque + _constraint_queue: deque + _init_modules: set[str] + updated_modules: list[str] + loaded_xmlids: set + db_name: str + _db: Connection + test_cr: Cursor | None + test_lock: RLock | None + loaded: bool + ready: bool + registry_sequence: int | None + cache_sequence: int | None + _invalidation_flags: threading.local + has_unaccent: bool + populated_models: dict[str, list[int]] + def init(self, db_name: str) -> None: ... @classmethod - def delete(cls, db_name: Any) -> None: ... + def delete(cls, db_name: str) -> None: ... @classmethod def delete_all(cls) -> None: ... - def __len__(self): ... - def __iter__(self) -> Any: ... - def __getitem__(self, model_name: Any): ... - def __call__(self, model_name: Any): ... - def __setitem__(self, model_name: Any, model: Any) -> None: ... - def descendants(self, model_names: Any, *kinds: Any): ... - def load(self, cr: Any, module: Any): ... - _m2m: Any = ... - field_triggers: Any = ... - def setup_models(self, cr: Any): ... - def post_init(self, func: Any, *args: Any, **kwargs: Any) -> None: ... - def post_constraint(self, func: Any, *args: Any, **kwargs: Any) -> None: ... + def __len__(self) -> int: ... + def __iter__(self) -> Iterator[str]: ... + def __getitem__(self, model_name: str) -> type[BaseModel]: ... + def __call__(self, model_name: str) -> type[BaseModel]: ... + def __setitem__(self, model_name: str, model: type[BaseModel]) -> None: ... + def descendants(self, model_names: Iterable[str], *kinds) -> set[str]: ... + def load(self, cr: Cursor, module: Node) -> set[str]: ... + _m2m: defaultdict[Any, list] + def setup_models(self, cr: Cursor) -> None: ... + def post_init(self, func: Callable, *args, **kwargs) -> None: ... + def post_constraint(self, func: Callable, *args, **kwargs) -> None: ... def finalize_constraints(self) -> None: ... - _is_install: Any = ... - def init_models(self, cr: Any, model_names: Any, context: Any, install: bool = ...) -> None: ... - def check_tables_exist(self, cr: Any) -> None: ... - def cache(self): ... + _is_install: bool + def init_models(self, cr: Cursor, model_names: Iterable[str], context: dict, install: bool = ...) -> None: ... + def check_tables_exist(self, cr: Cursor) -> None: ... + @property + def cache(self) -> LRU: ... def _clear_cache(self) -> None: ... def clear_caches(self) -> None: ... + @property + def registry_invalidated(self) -> bool: ... + @registry_invalidated.setter + def registry_invalidated(self, value: bool) -> None: ... + @property + def cache_invalidated(self) -> bool: ... + @cache_invalidated.setter + def cache_invalidated(self, value: bool) -> None: ... def setup_signaling(self) -> None: ... - def check_signaling(self): ... + def check_signaling(self) -> Registry: ... def signal_changes(self) -> None: ... def reset_changes(self) -> None: ... def manage_changes(self) -> None: ... - def in_test_mode(self): ... - def enter_test_mode(self, cr: Any) -> None: ... + def in_test_mode(self) -> bool: ... + def enter_test_mode(self, cr: Cursor) -> None: ... def leave_test_mode(self) -> None: ... def cursor(self) -> Cursor: ... @@ -73,4 +86,4 @@ class DummyRLock: def acquire(self) -> None: ... def release(self) -> None: ... def __enter__(self) -> None: ... - def __exit__(self, type: Any, value: Any, traceback: Any) -> None: ... + def __exit__(self, type, value, traceback) -> None: ...