diff --git a/odoo-stubs/__init__.pyi b/odoo-stubs/__init__.pyi index 31f19ef..b7caa79 100644 --- a/odoo-stubs/__init__.pyi +++ b/odoo-stubs/__init__.pyi @@ -1,22 +1,21 @@ from psycopg2 import connection -from . import ( - addons as addons, - api as api, - conf as conf, - fields as fields, - http as http, - loglevels as loglevels, - models as models, - netsvc as netsvc, - osv as osv, - release as release, - service as service, - sql_db as sql_db, - tools as tools -) +from . import addons as addons +from . import api as api +from . import conf as conf +from . import fields as fields +from . import http as http +from . import loglevels as loglevels +from . import models as models +from . import netsvc as netsvc +from . import osv as osv +from . import release as release +from . import service as service +from . import sql_db as sql_db +from . import tools as tools from .api import Registry -from .tools.translate import _ as _, _lt as _lt +from .tools.translate import _ as _ +from .tools.translate import _lt as _lt evented: bool diff --git a/odoo-stubs/api.pyi b/odoo-stubs/api.pyi index 367967b..2e3c619 100644 --- a/odoo-stubs/api.pyi +++ b/odoo-stubs/api.pyi @@ -1,6 +1,19 @@ from collections import defaultdict -from typing import Any, Callable, Generator, Iterable, Iterator, KeysView, Literal, Mapping, Optional, TypeVar, Union +from typing import ( + Any, + Callable, + Generator, + Iterable, + Iterator, + KeysView, + Literal, + Mapping, + Optional, + TypeVar, + Union, +) from weakref import WeakSet + from werkzeug.local import Local from .fields import Field @@ -9,9 +22,9 @@ from .modules.registry import Registry from .sql_db import Cursor from .tools import StackMap -_T = TypeVar('_T') -_ModelT = TypeVar('_ModelT', bound=BaseModel) -_CallableT = TypeVar('_CallableT', bound=Callable) +_T = TypeVar("_T") +_ModelT = TypeVar("_ModelT", bound=BaseModel) +_CallableT = TypeVar("_CallableT", bound=Callable) INHERITED_ATTRS: tuple[str, ...] @@ -30,17 +43,24 @@ def constrains(*args: str) -> Callable[[_T], _T]: ... def onchange(*args: str) -> Callable[[_T], _T]: ... def depends(*args: Union[str, Callable]) -> Callable[[_T], _T]: ... def depends_context(*args: str) -> Callable[[_T], _T]: ... -def returns(model: str | None, downgrade: Callable | None = ..., upgrade: Callable | None = ...) -> Callable[[_T], _T]: ... +def returns( + model: str | None, downgrade: Callable | None = ..., upgrade: Callable | None = ... +) -> Callable[[_T], _T]: ... def downgrade(method: Callable, value, self, args, kwargs): ... def split_context(method: Callable, args, kwargs) -> tuple: ... def model(method: _CallableT) -> _CallableT: ... - -def _model_create_single(create: Callable[..., _ModelT], self: _ModelT, arg) -> _ModelT: ... +def _model_create_single( + create: Callable[..., _ModelT], self: _ModelT, arg +) -> _ModelT: ... def model_create_single(method: _CallableT) -> _CallableT: ... -def _model_create_multi(create: Callable[..., _ModelT], self: _ModelT, arg) -> _ModelT: ... +def _model_create_multi( + create: Callable[..., _ModelT], self: _ModelT, arg +) -> _ModelT: ... def model_create_multi(method: _CallableT) -> _CallableT: ... def _call_kw_model(method: Callable[..., _ModelT], self: _ModelT, args, kwargs): ... -def _call_kw_model_create(method: Callable[..., _ModelT], self: _ModelT, args, kwargs) -> list[int] | int | Literal[False]: ... +def _call_kw_model_create( + method: Callable[..., _ModelT], self: _ModelT, args, kwargs +) -> list[int] | int | Literal[False]: ... def _call_kw_multi(method: Callable[..., _ModelT], self: _ModelT, args, kwargs): ... def call_kw(model: BaseModel, name: str, args, kwargs): ... @@ -60,7 +80,9 @@ class Environment(Mapping[str, BaseModel]): registry: Registry cache: Cache _protected: StackMap[Field, set[int]] - def __new__(cls, cr: Cursor, uid: int, context: dict, su: bool = ...) -> Environment: ... + def __new__( + cls, cr: Cursor, uid: int, context: dict, su: bool = ... + ) -> Environment: ... def __contains__(self, model_name: str) -> bool: ... def __getitem__(self, model_name: str) -> BaseModel: ... def __iter__(self) -> Iterator[str]: ... @@ -68,24 +90,34 @@ class Environment(Mapping[str, BaseModel]): def __eq__(self, other) -> bool: ... def __ne__(self, other) -> bool: ... def __hash__(self) -> int: ... - def __call__(self, cr: Cursor | None = ..., user: Union['odoo.model.res_users', int, None] = ..., context: dict | None = ..., su: bool | None = ...) -> Environment: ... - def ref(self, xml_id: str, raise_if_not_found: bool = ...) -> Optional[BaseModel]: ... + def __call__( + self, + cr: Cursor | None = ..., + user: Union["odoo.model.res_users", int, None] = ..., + context: dict | None = ..., + su: bool | None = ..., + ) -> Environment: ... + def ref( + self, xml_id: str, raise_if_not_found: bool = ... + ) -> Optional[BaseModel]: ... def is_superuser(self) -> bool: ... def is_admin(self) -> bool: ... def is_system(self) -> bool: ... @property - def user(self) -> 'odoo.model.res_users': ... + def user(self) -> "odoo.model.res_users": ... @property - def company(self) -> 'odoo.model.res_company': ... + def company(self) -> "odoo.model.res_company": ... @property - def companies(self) -> 'odoo.model.res_company': ... + def companies(self) -> "odoo.model.res_company": ... @property def lang(self) -> str: ... def clear(self) -> None: ... def clear_upon_failure(self) -> Generator[None, None, None]: ... def is_protected(self, field: Field, record: BaseModel) -> bool: ... def protected(self, field: Field) -> BaseModel: ... - def protecting(self, what, records: Optional[BaseModel] = ...) -> Generator[None, None, None]: ... + def protecting( + self, what, records: Optional[BaseModel] = ... + ) -> Generator[None, None, None]: ... def fields_to_compute(self) -> KeysView[Field]: ... def records_to_compute(self, field: Field) -> BaseModel: ... def is_to_compute(self, field: Field, record: BaseModel) -> bool: ... @@ -115,9 +147,13 @@ class Cache: def update(self, records: BaseModel, field: Field, values) -> None: ... def remove(self, record: BaseModel, field: Field) -> None: ... def get_values(self, records: BaseModel, field: Field) -> Iterator: ... - def get_records_different_from(self, records: _ModelT, field: Field, value) -> _ModelT: ... + def get_records_different_from( + self, records: _ModelT, field: Field, value + ) -> _ModelT: ... def get_fields(self, record: BaseModel) -> Iterator[Field]: ... def get_records(self, model: _ModelT, field: Field) -> _ModelT: ... def get_missing_ids(self, records: BaseModel, field: Field) -> Iterator[int]: ... - def invalidate(self, spec: list[tuple[Field, Iterable[int] | None]] | None = ...) -> None: ... + def invalidate( + self, spec: list[tuple[Field, Iterable[int] | None]] | None = ... + ) -> None: ... def check(self, env: Environment) -> None: ... diff --git a/odoo-stubs/fields.pyi b/odoo-stubs/fields.pyi index 9399e26..fc707aa 100644 --- a/odoo-stubs/fields.pyi +++ b/odoo-stubs/fields.pyi @@ -1,5 +1,16 @@ import datetime -from typing import Any, Callable, Collection, Generic, Iterator, Sequence, Type, TypeVar, Union, overload +from typing import ( + Any, + Callable, + Collection, + Generic, + Iterator, + Sequence, + Type, + TypeVar, + Union, + overload, +) import psycopg2 from markupsafe import Markup @@ -8,15 +19,15 @@ from .api import Environment from .models import BaseModel from .tools import date_utils, frozendict -_FieldT = TypeVar('_FieldT', bound=Field) -_FieldValueT = TypeVar('_FieldValueT') -_ModelT = TypeVar('_ModelT', bound=BaseModel) +_FieldT = TypeVar("_FieldT", bound=Field) +_FieldValueT = TypeVar("_FieldValueT") +_ModelT = TypeVar("_ModelT", bound=BaseModel) _Selection = list[tuple[str, str]] _SelectionRaw = _Selection | Callable[..., _Selection] | str _Domain = list _DomainRaw = _Domain | Callable[..., _Domain] _CommandList = list[tuple[BaseModel, list]] -_SeqIntT = TypeVar('_SeqIntT', bound=Sequence[int]) +_SeqIntT = TypeVar("_SeqIntT", bound=Sequence[int]) DATE_LENGTH: int DATETIME_LENGTH: int @@ -64,7 +75,7 @@ class Field(Generic[_FieldValueT], metaclass=MetaField): compute_sudo: bool inverse: str | Callable | None search: str | Callable | None - related: str| Sequence[str] | None + related: str | Sequence[str] | None company_dependent: bool default: Any string: str | None @@ -136,7 +147,9 @@ class Field(Generic[_FieldValueT], metaclass=MetaField): def _description_string(self, env: Environment) -> str | None: ... def _description_help(self, env: Environment) -> str | None: ... def null(self, record: BaseModel) -> bool: ... - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...): ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ): ... def convert_to_cache(self, value, record: BaseModel, validate: bool = ...): ... def convert_to_record(self, value, record: BaseModel): ... def convert_to_read(self, value, record: BaseModel, use_name_get: bool = ...): ... @@ -164,16 +177,24 @@ class Field(Generic[_FieldValueT], metaclass=MetaField): class Boolean(Field[bool]): type: str column_type: tuple[str, str] - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...) -> bool: ... - def convert_to_cache(self, value, record: BaseModel, validate: bool = ...) -> bool: ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ) -> bool: ... + def convert_to_cache( + self, value, record: BaseModel, validate: bool = ... + ) -> bool: ... def convert_to_export(self, value, record: BaseModel): ... class Integer(Field[int]): type: str column_type: tuple[str, str] _slots: dict[str, Any] - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...) -> int: ... - def convert_to_cache(self, value, record: BaseModel, validate: bool = ...) -> int | None: ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ) -> int: ... + def convert_to_cache( + self, value, record: BaseModel, validate: bool = ... + ) -> int | None: ... def convert_to_record(self, value, record: BaseModel): ... def convert_to_read(self, value, record: BaseModel, use_name_get: bool = ...): ... def _update(self, records: BaseModel, value) -> None: ... @@ -184,14 +205,20 @@ class Float(Field[float]): column_cast_from: tuple[str, str, str] _slots: dict[str, Any] _digits: tuple[int, int] | str | None - def __init__(self, string: str = ..., digits: tuple[int, int] | str | None =..., **kwargs) -> None: ... + def __init__( + self, string: str = ..., digits: tuple[int, int] | str | None = ..., **kwargs + ) -> None: ... @property def column_type(self): ... def get_digits(self, env: Environment) -> tuple[int, int]: ... _related__digits: Any def _description_digits(self, env: Environment) -> tuple[int, int]: ... - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...) -> float: ... - def convert_to_cache(self, value, record: BaseModel, validate: bool = ...) -> float: ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ) -> float: ... + def convert_to_cache( + self, value, record: BaseModel, validate: bool = ... + ) -> float: ... def convert_to_record(self, value, record: BaseModel): ... def convert_to_export(self, value, record: BaseModel): ... @@ -202,13 +229,19 @@ class Monetary(Field[float]): _slots: dict[str, Any] currency_field: str | None group_operator: str - def __init__(self, string: str = ..., currency_field : str =..., **kwargs) -> None: ... + def __init__( + self, string: str = ..., currency_field: str = ..., **kwargs + ) -> None: ... _description_currency_field: str | None def _setup_currency_field(self, model: BaseModel) -> None: ... def _setup_regular_full(self, model: BaseModel) -> None: ... def _setup_related_full(self, model: BaseModel) -> None: ... - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...) -> float: ... - def convert_to_cache(self, value, record: BaseModel, validate: bool = ...) -> float: ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ) -> float: ... + def convert_to_cache( + self, value, record: BaseModel, validate: bool = ... + ) -> float: ... def convert_to_record(self, value, record: BaseModel): ... def convert_to_read(self, value, record: BaseModel, use_name_get: bool = ...): ... def convert_to_write(self, value, record: BaseModel): ... @@ -240,8 +273,12 @@ class Char(_String): _description_size: int | None _description_trim: bool def _setup_regular_base(self, model: BaseModel) -> None: ... - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...) -> str | None: ... - def convert_to_cache(self, value, record: BaseModel, validate: bool = ...) -> str | None: ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ) -> str | None: ... + def convert_to_cache( + self, value, record: BaseModel, validate: bool = ... + ) -> str | None: ... class Text(_String): type: str @@ -273,8 +310,12 @@ class Html(_String): _description_sanitize_style: bool _description_strip_style: bool _description_strip_classes: bool - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...) -> Markup | None: ... - def convert_to_cache(self, value, record: BaseModel, validate: bool = ...) -> Markup | None: ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ) -> Markup | None: ... + def convert_to_cache( + self, value, record: BaseModel, validate: bool = ... + ) -> Markup | None: ... class Date(Field[datetime.date]): type: str @@ -287,13 +328,17 @@ class Date(Field[datetime.date]): @staticmethod def today(*args) -> datetime.date: ... @staticmethod - def context_today(record: BaseModel, timestamp: datetime.datetime | None = ...) -> datetime.date: ... + def context_today( + record: BaseModel, timestamp: datetime.datetime | None = ... + ) -> datetime.date: ... @staticmethod def to_date(value) -> datetime.date | None: ... from_string = to_date @staticmethod def to_string(value: datetime.datetime | datetime.date) -> str: ... - def convert_to_cache(self, value, record: BaseModel, validate: bool = ...) -> datetime.date | None: ... + def convert_to_cache( + self, value, record: BaseModel, validate: bool = ... + ) -> datetime.date | None: ... def convert_to_export(self, value, record: BaseModel): ... class Datetime(Field[datetime.datetime]): @@ -309,13 +354,17 @@ class Datetime(Field[datetime.datetime]): @staticmethod def today(*args) -> datetime.datetime: ... @staticmethod - def context_timestamp(record: BaseModel, timestamp: datetime.datetime) -> datetime.datetime: ... + def context_timestamp( + record: BaseModel, timestamp: datetime.datetime + ) -> datetime.datetime: ... @staticmethod def to_datetime(value) -> datetime.datetime | None: ... from_string = to_datetime @staticmethod def to_string(value: datetime.datetime | datetime.date) -> str: ... - def convert_to_cache(self, value, record: BaseModel, validate: bool = ...) -> datetime.datetime | None: ... + def convert_to_cache( + self, value, record: BaseModel, validate: bool = ... + ) -> datetime.datetime | None: ... def convert_to_export(self, value, record: BaseModel): ... def convert_to_display_name(self, value, record: BaseModel) -> str: ... @@ -331,8 +380,12 @@ class Binary(Field[bytes]): def column_type(self) -> tuple[str, str] | None: ... def _get_attrs(self, model: BaseModel, name: str) -> dict[str, Any]: ... _description_attachment: bool - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...) -> psycopg2.Binary | None: ... - def convert_to_cache(self, value, record: BaseModel, validate: bool = ...) -> bytes | None: ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ) -> psycopg2.Binary | None: ... + def convert_to_cache( + self, value, record: BaseModel, validate: bool = ... + ) -> bytes | None: ... def convert_to_record(self, value, record: BaseModel) -> bytes: ... def compute_value(self, records: BaseModel) -> None: ... def read(self, records: BaseModel) -> None: ... @@ -355,14 +408,18 @@ class Selection(Field[str]): _slots: dict[str, Any] selection: _SelectionRaw validate: bool - def __init__(self, selection: _SelectionRaw = ..., string: str = ..., **kwargs) -> None: ... + def __init__( + self, selection: _SelectionRaw = ..., string: str = ..., **kwargs + ) -> None: ... def _setup_regular_base(self, model: BaseModel) -> None: ... def _setup_related_full(self, model: BaseModel) -> None: ... def _setup_attrs(self, model: BaseModel, name: str) -> None: ... def _selection_modules(self, model: BaseModel) -> dict[str, set[str, str]]: ... def _description_selection(self, env: Environment) -> _Selection: ... def get_values(self, env: Environment) -> list[str]: ... - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...): ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ): ... def convert_to_cache(self, value, record: BaseModel, validate: bool = ...): ... def convert_to_export(self, value, record: BaseModel): ... @@ -370,10 +427,16 @@ class Reference(Selection): type: str @property def column_type(self) -> tuple[str, str]: ... - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...) -> str | None: ... - def convert_to_cache(self, value, record: BaseModel, validate: bool = ...) -> str | None: ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ) -> str | None: ... + def convert_to_cache( + self, value, record: BaseModel, validate: bool = ... + ) -> str | None: ... def convert_to_record(self, value, record: BaseModel) -> Union[BaseModel, None]: ... - def convert_to_read(self, value, record: BaseModel, use_name_get: bool = ...) -> str | bool: ... + def convert_to_read( + self, value, record: BaseModel, use_name_get: bool = ... + ) -> str | bool: ... def convert_to_export(self, value, record: BaseModel) -> str: ... def convert_to_display_name(self, value, record: BaseModel) -> str: ... @@ -401,14 +464,18 @@ class Many2one(_Relational): ondelete: str | None auto_join: bool delegate: bool - def __init__(self, comodel_name: str = ..., string: str = ..., **kwargs) -> None: ... + def __init__( + self, comodel_name: str = ..., string: str = ..., **kwargs + ) -> None: ... def _setup_attrs(self, model: BaseModel, name: str) -> None: ... def _setup_regular_base(self, model: BaseModel) -> None: ... def update_db(self, model: BaseModel, columns): ... def update_db_column(self, model: BaseModel, column) -> None: ... def update_db_foreign_key(self, model: BaseModel, column) -> None: ... def _update(self, records: BaseModel, value) -> None: ... - def convert_to_column(self, value, record: BaseModel, values: Any | None = ..., validate: bool = ...): ... + def convert_to_column( + self, value, record: BaseModel, values: Any | None = ..., validate: bool = ... + ): ... def convert_to_cache(self, value, record: BaseModel, validate: bool = ...): ... def convert_to_record(self, value, record: BaseModel): ... def convert_to_read(self, value, record: BaseModel, use_name_get: bool = ...): ... @@ -451,7 +518,13 @@ class One2many(_RelationalMulti): auto_join: bool limit: int | None copy: bool - def __init__(self, comodel_name: str = ..., inverse_name: str = ..., string: str = ..., **kwargs) -> None: ... + def __init__( + self, + comodel_name: str = ..., + inverse_name: str = ..., + string: str = ..., + **kwargs + ) -> None: ... def _setup_regular_full(self, model: BaseModel) -> None: ... _description_relation_field: str | None def update_db(self, model: BaseModel, columns) -> None: ... @@ -470,7 +543,15 @@ class Many2many(_RelationalMulti): auto_join: bool limit: int | None ondelete: str - def __init__(self, comodel_name: str =..., relation: str = ..., column1: str = ..., column2: str = ..., string: str = ..., **kwargs) -> None: ... + def __init__( + self, + comodel_name: str = ..., + relation: str = ..., + column1: str = ..., + column2: str = ..., + string: str = ..., + **kwargs + ) -> None: ... def _setup_regular_base(self, model: BaseModel) -> None: ... def _setup_regular_full(self, model: BaseModel) -> None: ... def update_db(self, model: BaseModel, columns) -> None: ... diff --git a/odoo-stubs/http.pyi b/odoo-stubs/http.pyi index dce2a14..20d868f 100644 --- a/odoo-stubs/http.pyi +++ b/odoo-stubs/http.pyi @@ -12,7 +12,7 @@ from .api import Environment from .modules.registry import Registry from .sql_db import Cursor -_T = TypeVar('_T') +_T = TypeVar("_T") rpc_request: Logger rpc_response: Logger @@ -27,7 +27,9 @@ def replace_request_password(args) -> tuple: ... NO_POSTMORTEM: tuple[type[Exception], ...] def dispatch_rpc(service_name: str, method: str, params): ... -def local_redirect(path: str, query: dict | None = ..., keep_hash: bool = ..., code: int = ...) -> werkzeug.wrappers.Response: ... +def local_redirect( + path: str, query: dict | None = ..., keep_hash: bool = ..., code: int = ... +) -> werkzeug.wrappers.Response: ... def redirect_with_hash(url: str, code: int = ...) -> werkzeug.wrappers.Response: ... class WebRequest: @@ -37,11 +39,11 @@ class WebRequest: endpoint: EndPoint | None endpoint_arguments: Any auth_method: str | None - website: 'odoo.model.website' + website: "odoo.model.website" website_routing: int is_frontend: bool is_frontend_multilang: bool - lang: 'odoo.model.res_lang' + lang: "odoo.model.res_lang" _cr: Cursor | None _uid: int | None _context: dict | None @@ -75,13 +77,15 @@ class WebRequest: def csrf_token(self, time_limit: int | None = ...): ... def validate_csrf(self, csrf) -> bool: ... -def route(route: str | list[str] | None = ..., - type: str = ..., - auth: str = ..., - methods: list[str] = ..., - cors: str = ..., - csrf: bool = ..., - **kw): ... +def route( + route: str | list[str] | None = ..., + type: str = ..., + auth: str = ..., + methods: list[str] = ..., + cors: str = ..., + csrf: bool = ..., + **kw +): ... class JsonRequest(WebRequest): _request_type: str @@ -89,7 +93,9 @@ class JsonRequest(WebRequest): jsonrequest: Any context: dict def __init__(self, *args) -> None: ... - def _json_response(self, result: Any | None = ..., error: dict | None = ...) -> Response: ... + def _json_response( + self, result: Any | None = ..., error: dict | None = ... + ) -> Response: ... def _handle_exception(self, exception: Exception) -> Response: ... def dispatch(self) -> Response: ... @@ -101,8 +107,15 @@ class HttpRequest(WebRequest): def __init__(self, *args) -> None: ... def _handle_exception(self, exception: Exception): ... def dispatch(self): ... - def make_response(self, data, headers: list[tuple[str, str]] | None = ..., cookies: dict | None = ...) -> Response: ... - def render(self, template, qcontext: dict | None = ..., lazy: bool = ..., **kw) -> Response: ... + def make_response( + self, + data, + headers: list[tuple[str, str]] | None = ..., + cookies: dict | None = ..., + ) -> Response: ... + def render( + self, template, qcontext: dict | None = ..., lazy: bool = ..., **kw + ) -> Response: ... def not_found(self, description: str | Any | None = ...) -> NotFound: ... addons_manifest: dict @@ -111,7 +124,7 @@ controllers_per_module: dict[str, list] class ControllerType(type): def __init__(cls, name: str, bases: tuple, attrs: dict) -> None: ... -Controller = ControllerType('Controller', (object,), {}) +Controller = ControllerType("Controller", (object,), {}) class EndPoint: method: Callable @@ -127,7 +140,9 @@ class EndPoint: def _as_tuple(self) -> tuple[Callable, dict]: ... def __repr__(self) -> str: ... -def _generate_routing_rules(modules: Collection[str], nodb_only: bool, converters: Any | None = ...) -> Generator[tuple[str, EndPoint, dict], None, None]: ... +def _generate_routing_rules( + modules: Collection[str], nodb_only: bool, converters: Any | None = ... +) -> Generator[tuple[str, EndPoint, dict], None, None]: ... class AuthenticationError(Exception): ... class SessionExpiredException(Exception): ... @@ -143,7 +158,13 @@ class OpenERPSession(werkzeug.contrib.sessions.Session): uid: int login: str | None session_token: str | None - def authenticate(self, db: str, login: str | None = ..., password: str | None = ..., uid: int | None = ...) -> int: ... + def authenticate( + self, + db: str, + login: str | None = ..., + password: str | None = ..., + uid: int | None = ..., + ) -> int: ... def check_security(self) -> None: ... def logout(self, keep_db: bool = ...) -> None: ... def _default_values(self) -> None: ... @@ -155,7 +176,9 @@ class OpenERPSession(werkzeug.contrib.sessions.Session): def save_request_data(self) -> None: ... def load_request_data(self) -> Generator[CombinedMultiDict | None, None, None]: ... -def session_gc(session_store: werkzeug.contrib.sessions.FilesystemSessionStore) -> None: ... +def session_gc( + session_store: werkzeug.contrib.sessions.FilesystemSessionStore, +) -> None: ... class Response(werkzeug.wrappers.Response): default_mimetype: str @@ -163,7 +186,12 @@ class Response(werkzeug.wrappers.Response): template: Any qcontext: dict uid: int - def set_default(self, template: Any | None = ..., qcontext: dict | None = ..., uid: int | None = ...) -> None: ... + def set_default( + self, + template: Any | None = ..., + qcontext: dict | None = ..., + uid: int | None = ..., + ) -> None: ... @property def is_qweb(self) -> bool: ... def render(self): ... @@ -186,16 +214,33 @@ class Root: def setup_session(self, httprequest: werkzeug.wrappers.Request) -> bool: ... def setup_db(self, httprequest: werkzeug.wrappers.Request) -> None: ... def setup_lang(self, httprequest: werkzeug.wrappers.Request) -> None: ... - def get_request(self, httprequest: werkzeug.wrappers.Request) -> HttpRequest | JsonRequest: ... - def get_response(self, httprequest: werkzeug.wrappers.Request, result, explicit_session: bool) -> Any: ... + def get_request( + self, httprequest: werkzeug.wrappers.Request + ) -> HttpRequest | JsonRequest: ... + def get_response( + self, httprequest: werkzeug.wrappers.Request, result, explicit_session: bool + ) -> Any: ... def set_csp(self, response: werkzeug.wrappers.Response) -> None: ... def dispatch(self, environ: dict, start_response: Callable): ... def get_db_router(self, db: str) -> Map: ... -def db_list(force: bool = ..., httprequest: werkzeug.wrappers.Request | None = ...) -> list[str]: ... -def db_filter(dbs, httprequest: werkzeug.wrappers.Request | None = ...) -> list[str]: ... +def db_list( + force: bool = ..., httprequest: werkzeug.wrappers.Request | None = ... +) -> list[str]: ... +def db_filter( + dbs, httprequest: werkzeug.wrappers.Request | None = ... +) -> list[str]: ... def db_monodb(httprequest: werkzeug.wrappers.Request | None = ...) -> str | None: ... -def send_file(filepath_or_fp, mimetype: str | None = ..., as_attachment: bool = ..., filename: str | None = ..., mtime: Any | None = ..., add_etags: bool = ..., cache_timeout: int =..., conditional: bool = ...) -> Response: ... +def send_file( + filepath_or_fp, + mimetype: str | None = ..., + as_attachment: bool = ..., + filename: str | None = ..., + mtime: Any | None = ..., + add_etags: bool = ..., + cache_timeout: int = ..., + conditional: bool = ..., +) -> Response: ... def content_disposition(filename: str) -> str: ... def set_safe_image_headers(headers, content): ... diff --git a/odoo-stubs/models.pyi b/odoo-stubs/models.pyi index 8d54375..434217e 100644 --- a/odoo-stubs/models.pyi +++ b/odoo-stubs/models.pyi @@ -1,6 +1,19 @@ from collections import defaultdict from re import Pattern -from typing import Any, Callable, Collection, Container, Iterable, Iterator, Literal, MutableMapping, Sequence, TypeVar, Union, overload +from typing import ( + Any, + Callable, + Collection, + Container, + Iterable, + Iterator, + Literal, + MutableMapping, + Sequence, + TypeVar, + Union, + overload, +) import psycopg2 from lxml.etree import _Element @@ -12,8 +25,8 @@ from .modules.registry import Registry from .osv.query import Query from .sql_db import Cursor -_T = TypeVar('_T') -_ModelT = TypeVar('_ModelT', bound=BaseModel) +_T = TypeVar("_T") +_ModelT = TypeVar("_ModelT", bound=BaseModel) _Domain = list regex_order: Pattern[str] @@ -35,7 +48,9 @@ def trigger_tree_merge(node1: dict, node2: dict) -> None: ... class MetaModel(api.Meta): module_to_models: defaultdict[str, list[type[BaseModel]]] - def __init__(self: type[BaseModel], name: str, bases: tuple, attrs: dict) -> None: ... + def __init__( + self: type[BaseModel], name: str, bases: tuple, attrs: dict + ) -> None: ... def _get_addon_name(self, full_name: str) -> str: ... class NewId: @@ -96,11 +111,11 @@ class BaseModel(metaclass=MetaModel): env: Environment = ... pool: Registry id = fields.Id() - display_name = fields.Char(string='Display Name') - create_uid = fields.Many2one('res.users', string='Created by') - create_date = fields.Datetime(string='Created on') - write_uid = fields.Many2one('res.users', string='Last Updated by') - write_date = fields.Datetime(string='Last Updated on') + display_name = fields.Char(string="Display Name") + create_uid = fields.Many2one("res.users", string="Created by") + create_date = fields.Datetime(string="Created on") + write_uid = fields.Many2one("res.users", string="Last Updated by") + write_date = fields.Datetime(string="Last Updated on") CONCURRENCY_CHECK_FIELD: str def view_init(self, fields_list: list[str]) -> None: ... def _reflect(self) -> None: ... @@ -114,7 +129,9 @@ class BaseModel(metaclass=MetaModel): @classmethod def _build_model_check_base(model_class, cls: type[BaseModel]) -> None: ... @classmethod - def _build_model_check_parent(model_class, cls: type[BaseModel], parent_class: type[BaseModel]) -> None: ... + def _build_model_check_parent( + model_class, cls: type[BaseModel], parent_class: type[BaseModel] + ) -> None: ... @classmethod def _build_model_attributes(cls, pool: Registry) -> None: ... @classmethod @@ -126,15 +143,31 @@ class BaseModel(metaclass=MetaModel): def __new__(cls) -> None: ... def __init__(self, pool: Registry, cr: Cursor) -> None: ... def _is_an_ordinary_table(self) -> bool: ... - def __ensure_xml_id(self: _ModelT, skip: bool = ...) -> Iterator[tuple[_ModelT, str | None]]: ... - def _export_rows(self, fields: list[list[str]], *, _is_toplevel_call: bool = ...) -> list[list]: ... + def __ensure_xml_id( + self: _ModelT, skip: bool = ... + ) -> Iterator[tuple[_ModelT, str | None]]: ... + def _export_rows( + self, fields: list[list[str]], *, _is_toplevel_call: bool = ... + ) -> list[list]: ... __export_rows = _export_rows def export_data(self, fields_to_export: list[str]) -> dict[str, list[list]]: ... def load(self, fields: list[str], data: list[list[str]]) -> dict[str, Any]: ... - def _add_fake_fields(self, fields: dict[str | None, Field]) -> dict[str | None, Field]: ... - def _extract_records(self, fields_: Iterable[Sequence[str]], data, log: Callable = ..., limit: float = ...) -> Iterator[tuple[BaseModel, dict[str, dict[str, int]]]]: ... - def _convert_records(self, records, log: Callable = ...) -> Iterator[tuple[Any, Any, Any, dict]]: ... - def _validate_fields(self, field_names: Iterable[str], excluded_names: Iterable[str] = ...) -> None: ... + def _add_fake_fields( + self, fields: dict[str | None, Field] + ) -> dict[str | None, Field]: ... + def _extract_records( + self, + fields_: Iterable[Sequence[str]], + data, + log: Callable = ..., + limit: float = ..., + ) -> Iterator[tuple[BaseModel, dict[str, dict[str, int]]]]: ... + def _convert_records( + self, records, log: Callable = ... + ) -> Iterator[tuple[Any, Any, Any, dict]]: ... + def _validate_fields( + self, field_names: Iterable[str], excluded_names: Iterable[str] = ... + ) -> None: ... def default_get(self, fields_list: list[str]) -> dict[str, Any]: ... def fields_get_keys(self) -> list[str]: ... def _rec_name_fallback(self) -> str: ... @@ -148,35 +181,129 @@ class BaseModel(metaclass=MetaModel): def _get_default_graph_view(self) -> _Element: ... def _get_default_calendar_view(self) -> _Element: ... def load_views(self, views: list, options: dict | None = ...) -> dict[str, Any]: ... - def _fields_view_get(self, view_id: int | None = ..., view_type: str = ..., toolbar: bool = ..., submenu: bool = ...) -> dict[str, Any]: ... - def fields_view_get(self, view_id: int | None = ..., view_type: str = ..., toolbar: bool = ..., submenu: bool = ...) -> dict[str, Any]: ... + def _fields_view_get( + self, + view_id: int | None = ..., + view_type: str = ..., + toolbar: bool = ..., + submenu: bool = ..., + ) -> dict[str, Any]: ... + def fields_view_get( + self, + view_id: int | None = ..., + view_type: str = ..., + toolbar: bool = ..., + submenu: bool = ..., + ) -> dict[str, Any]: ... def get_formview_id(self, access_uid: int | None = ...): ... def get_formview_action(self, access_uid: int | None = ...) -> dict[str, Any]: ... def get_access_action(self, access_uid: int | None = ...) -> dict[str, Any]: ... def search_count(self, args: _Domain) -> int: ... @overload - def search(self: _ModelT, args: _Domain, offset: int = ..., limit: int | None = ..., order: str | None = ..., count: Literal[False] = ...) -> _ModelT: ... + def search( + self: _ModelT, + args: _Domain, + offset: int = ..., + limit: int | None = ..., + order: str | None = ..., + count: Literal[False] = ..., + ) -> _ModelT: ... @overload - def search(self: _ModelT, args: _Domain, offset: int = ..., limit: int | None = ..., order: str | None = ..., count: Literal[True] = ...) -> int: ... + def search( + self: _ModelT, + args: _Domain, + offset: int = ..., + limit: int | None = ..., + order: str | None = ..., + count: Literal[True] = ..., + ) -> int: ... def _compute_display_name(self) -> None: ... def name_get(self) -> list[tuple[int, str]]: ... def name_create(self, name: str) -> tuple[int, str]: ... - def name_search(self, name: str = ..., args: _Domain | None = ..., operator: str = ..., limit: int = ...) -> list[tuple[int, str]]: ... - def _name_search(self, name: str = ..., args: _Domain | None = ..., operator: str = ..., limit: int = ..., name_get_uid: int | None = ...) -> list[int]: ... + def name_search( + self, + name: str = ..., + args: _Domain | None = ..., + operator: str = ..., + limit: int = ..., + ) -> list[tuple[int, str]]: ... + def _name_search( + self, + name: str = ..., + args: _Domain | None = ..., + operator: str = ..., + limit: int = ..., + name_get_uid: int | None = ..., + ) -> list[int]: ... def _add_missing_default_values(self, values: dict[str, Any]) -> dict[str, Any]: ... @classmethod def clear_caches(cls) -> None: ... - def _read_group_fill_results(self, domain: _Domain, groupby: str, remaining_groupbys: list[str], aggregated_fields: list[str], count_field: str, read_group_result, read_group_order: str | None = ...) -> list: ... - def _read_group_fill_temporal(self, data: list, groupby: list[str], aggregated_fields: list[str], annotated_groupbys: list[dict], interval = ...) -> list: ... - def _read_group_prepare(self, orderby: str, aggregated_fields: list[str], annotated_groupbys: list[dict], query: Query) -> tuple[list, list]: ... + def _read_group_fill_results( + self, + domain: _Domain, + groupby: str, + remaining_groupbys: list[str], + aggregated_fields: list[str], + count_field: str, + read_group_result, + read_group_order: str | None = ..., + ) -> list: ... + def _read_group_fill_temporal( + self, + data: list, + groupby: list[str], + aggregated_fields: list[str], + annotated_groupbys: list[dict], + interval=..., + ) -> list: ... + def _read_group_prepare( + self, + orderby: str, + aggregated_fields: list[str], + annotated_groupbys: list[dict], + query: Query, + ) -> tuple[list, list]: ... def _read_group_process_groupby(self, gb: str, query: Query) -> dict[str, Any]: ... - def _read_group_prepare_data(self, key, value, groupby_dict: dict[str, dict[str, Any]]) -> Any: ... - def _read_group_format_result(self, data: dict, annotated_groupbys: list[dict], groupby: list, domain: _Domain) -> dict: ... - def read_group(self, domain: _Domain, fields: list[str], groupby: str | list[str], offset: int = ..., limit: int | None = ..., orderby: str | None = ..., lazy: bool = ...) -> list[dict[str, Any]]: ... - def _read_group_raw(self, domain: _Domain, fields: list[str], groupby: str | list[str], offset: int = ..., limit: int | None = ..., orderby: str | None = ..., lazy: bool = ...) -> list[dict[str, Any]]: ... - def _read_group_resolve_many2one_fields(self, data: list[dict[str, Any]], fields: list[dict[str, Any]]) -> None: ... - def _inherits_join_add(self, current_model: BaseModel, parent_model_name: str, query: Query) -> str: ... - def _inherits_join_calc(self, alias: str, fname: str, query: Query, implicit: bool = ..., outer: bool = ...) -> str: ... + def _read_group_prepare_data( + self, key, value, groupby_dict: dict[str, dict[str, Any]] + ) -> Any: ... + def _read_group_format_result( + self, data: dict, annotated_groupbys: list[dict], groupby: list, domain: _Domain + ) -> dict: ... + def read_group( + self, + domain: _Domain, + fields: list[str], + groupby: str | list[str], + offset: int = ..., + limit: int | None = ..., + orderby: str | None = ..., + lazy: bool = ..., + ) -> list[dict[str, Any]]: ... + def _read_group_raw( + self, + domain: _Domain, + fields: list[str], + groupby: str | list[str], + offset: int = ..., + limit: int | None = ..., + orderby: str | None = ..., + lazy: bool = ..., + ) -> list[dict[str, Any]]: ... + def _read_group_resolve_many2one_fields( + self, data: list[dict[str, Any]], fields: list[dict[str, Any]] + ) -> None: ... + def _inherits_join_add( + self, current_model: BaseModel, parent_model_name: str, query: Query + ) -> str: ... + def _inherits_join_calc( + self, + alias: str, + fname: str, + query: Query, + implicit: bool = ..., + outer: bool = ..., + ) -> str: ... def _parent_store_compute(self): ... def _check_removed_columns(self, log: bool = ...) -> None: ... def _init_column(self, column_name: str) -> None: ... @@ -192,24 +319,32 @@ class BaseModel(metaclass=MetaModel): def _setup_base(self) -> None: ... def _setup_fields(self) -> None: ... def _setup_complete(self) -> None: ... - def fields_get(self, allfields: list[str] | None = ..., attributes: list[str] | None = ...) -> dict[str, dict[str, Any]]: ... + def fields_get( + self, allfields: list[str] | None = ..., attributes: list[str] | None = ... + ) -> dict[str, dict[str, Any]]: ... def get_empty_list_help(self, help: str) -> str: ... def check_field_access_rights(self, operation: str, fields: Collection[str]): ... - def read(self, fields: Collection[str] | None = ..., load: str = ...) -> list[dict[str, Any]]: ... + def read( + self, fields: Collection[str] | None = ..., load: str = ... + ) -> list[dict[str, Any]]: ... def _fetch_field(self, field: Field) -> None: ... def _read(self, fields: Collection[str]): ... def get_metadata(self) -> list[dict[str, Any]]: ... def get_base_url(self) -> str: ... def _check_concurrency(self) -> None: ... def _check_company(self, fnames: Collection[str] | None = ...) -> None: ... - def check_access_rights(self, operation: str, raise_exception: bool = ...) -> bool: ... + def check_access_rights( + self, operation: str, raise_exception: bool = ... + ) -> bool: ... def check_access_rule(self, operation: str) -> None: ... def _filter_access_rules(self: _ModelT, operation: str) -> _ModelT: ... def _filter_access_rules_python(self, operation: str) -> _ModelT: ... def unlink(self): ... def write(self, vals: dict[str, Any]): ... def _write(self, vals: dict[str, Any]): ... - def create(self: _ModelT, vals_list: list[dict[str, Any]] | dict[str, Any]) -> _ModelT: ... + def create( + self: _ModelT, vals_list: list[dict[str, Any]] | dict[str, Any] + ) -> _ModelT: ... def _create(self: _ModelT, data_list: list[dict[str, Any]]) -> _ModelT: ... def _compute_field_value(self, field: Field) -> None: ... def _parent_store_create(self) -> None: ... @@ -221,14 +356,48 @@ class BaseModel(metaclass=MetaModel): def _where_calc(self, domain: _Domain, active_test: bool = ...) -> Query: ... def _check_qorder(self, word: str) -> bool: ... def _apply_ir_rules(self, query: Query, mode: str = ...) -> None: ... - def _generate_translated_field(self, table_alias: str, field: str, query: Query) -> str: ... - def _generate_m2o_order_by(self, alias: str, order_field: str, query: Query, reverse_direction: bool, seen: set | None) -> list[str]: ... - def _generate_order_by_inner(self, alias: str, order_spec: str, query: Query, reverse_direction: bool = ..., seen: set | None = ...) -> list[str]: ... + def _generate_translated_field( + self, table_alias: str, field: str, query: Query + ) -> str: ... + def _generate_m2o_order_by( + self, + alias: str, + order_field: str, + query: Query, + reverse_direction: bool, + seen: set | None, + ) -> list[str]: ... + def _generate_order_by_inner( + self, + alias: str, + order_spec: str, + query: Query, + reverse_direction: bool = ..., + seen: set | None = ..., + ) -> list[str]: ... def _generate_order_by(self, order_spec: str | None, query: Query) -> str: ... - def _flush_search(self, domain: _Domain, fields: Sequence[str] | None = ..., order: str | None = ..., seen: set | None = ...) -> None: ... - def _search(self: _ModelT, args: _Domain, offset: int = ..., limit: int | None = ..., order: str | None = ..., count: bool = ..., access_rights_uid: int | None = ...) -> Query | int: ... - def copy_data(self, default: dict[str, Any] | None = ...) -> list[dict[str, Any]]: ... - def copy_translations(old: _ModelT, new: _ModelT, excluded: Container[str] = ...) -> None: ... + def _flush_search( + self, + domain: _Domain, + fields: Sequence[str] | None = ..., + order: str | None = ..., + seen: set | None = ..., + ) -> None: ... + def _search( + self: _ModelT, + args: _Domain, + offset: int = ..., + limit: int | None = ..., + order: str | None = ..., + count: bool = ..., + access_rights_uid: int | None = ..., + ) -> Query | int: ... + def copy_data( + self, default: dict[str, Any] | None = ... + ) -> list[dict[str, Any]]: ... + def copy_translations( + old: _ModelT, new: _ModelT, excluded: Container[str] = ... + ) -> None: ... def copy(self: _ModelT, default: dict[str, Any] | None = ...) -> _ModelT: ... def exists(self: _ModelT) -> _ModelT: ... def _check_recursion(self, parent: str | None = ...) -> bool: ... @@ -242,9 +411,18 @@ class BaseModel(metaclass=MetaModel): def _transient_clean_rows_older_than(self, seconds: int) -> None: ... def _transient_clean_old_rows(self, max_count: int) -> None: ... def _transient_vacuum(self, force: bool = ...): ... - def resolve_2many_commands(self, field_name: str, commands: list, fields: list[str] | None = ...): ... + def resolve_2many_commands( + self, field_name: str, commands: list, fields: list[str] | None = ... + ): ... resolve_o2m_commands_to_record_dicts = resolve_2many_commands - def search_read(self, domain: _Domain | None = ..., fields: list[str] | None = ..., offset: int = ..., limit: int | None = ..., order: str | None = ...) -> list[dict[str, Any]]: ... + def search_read( + self, + domain: _Domain | None = ..., + fields: list[str] | None = ..., + offset: int = ..., + limit: int | None = ..., + order: str | None = ..., + ) -> list[dict[str, Any]]: ... def toggle_active(self) -> None: ... def action_archive(self): ... def action_unarchive(self): ... @@ -255,8 +433,12 @@ class BaseModel(metaclass=MetaModel): @classmethod def _revert_method(cls, name: str) -> None: ... @classmethod - def _browse(cls: type[_ModelT], env: Environment, ids: tuple, prefetch_ids: Iterable[int]) -> _ModelT: ... - def browse(self: _ModelT, ids: int | NewId | Iterable[int | NewId] | None = ...) -> _ModelT: ... + def _browse( + cls: type[_ModelT], env: Environment, ids: tuple, prefetch_ids: Iterable[int] + ) -> _ModelT: ... + def browse( + self: _ModelT, ids: int | NewId | Iterable[int | NewId] | None = ... + ) -> _ModelT: ... @property def ids(self) -> list[int]: ... _cr: Cursor @@ -265,9 +447,13 @@ class BaseModel(metaclass=MetaModel): def ensure_one(self: _ModelT) -> _ModelT: ... def with_env(self: _ModelT, env: Environment) -> _ModelT: ... def sudo(self: _ModelT, flag: bool = ...) -> _ModelT: ... - def with_user(self: _ModelT, user: Union['odoo.model.res_partner', int]) -> _ModelT: ... + def with_user( + self: _ModelT, user: Union["odoo.model.res_partner", int] + ) -> _ModelT: ... def with_context(self: _ModelT, *args, **kwargs) -> _ModelT: ... - def with_prefetch(self: _ModelT, prefetch_ids: Iterable[int] | None = ...) -> _ModelT: ... + def with_prefetch( + self: _ModelT, prefetch_ids: Iterable[int] | None = ... + ) -> _ModelT: ... def _update_cache(self, values: dict[str, Any], validate: bool = ...): ... def _convert_to_record(self, values: dict[str, Any]): ... def _convert_to_write(self, values: dict[str, Any]) -> dict[str, Any]: ... @@ -276,10 +462,19 @@ class BaseModel(metaclass=MetaModel): def _mapped_cache(self, name_seq: str): ... def filtered(self: _ModelT, func: Callable | str) -> _ModelT: ... def filtered_domain(self: _ModelT, domain: _Domain) -> _ModelT: ... - def sorted(self: _ModelT, key: Callable | str | None = ..., reverse: bool = ...) -> _ModelT: ... + def sorted( + self: _ModelT, key: Callable | str | None = ..., reverse: bool = ... + ) -> _ModelT: ... def update(self, values: dict[str, Any]) -> None: ... - def flush(self, fnames: Collection[str] | None = ..., records: BaseModel | None = ...) -> None: ... - def new(self: _ModelT, values: dict[str, Any] = ..., origin: _ModelT | None = ..., ref: Any | None = ...) -> _ModelT: ... + def flush( + self, fnames: Collection[str] | None = ..., records: BaseModel | None = ... + ) -> None: ... + def new( + self: _ModelT, + values: dict[str, Any] = ..., + origin: _ModelT | None = ..., + ref: Any | None = ..., + ) -> _ModelT: ... @property def _origin(self: _ModelT) -> _ModelT: ... def __bool__(self) -> bool: ... @@ -306,15 +501,30 @@ class BaseModel(metaclass=MetaModel): def _cache(self) -> RecordCache: ... def _in_cache_without(self: _ModelT, field: Field, limit: int = ...) -> _ModelT: ... def refresh(self) -> None: ... - def invalidate_cache(self, fnames: Collection[str] | None = ..., ids: Iterable[int] | None = ...) -> None: ... - def modified(self, fnames: Collection[str], create: bool = ..., before: bool = ...) -> None: ... - def _modified_triggers(self: _ModelT, tree: dict[Field | None, Any], create: bool = ...) -> Iterator[tuple[Field, _ModelT, bool]]: ... - def recompute(self, fnames: Collection[str] | None = ..., records: Union[BaseModel, None] = ...) -> None: ... + def invalidate_cache( + self, fnames: Collection[str] | None = ..., ids: Iterable[int] | None = ... + ) -> None: ... + def modified( + self, fnames: Collection[str], create: bool = ..., before: bool = ... + ) -> None: ... + def _modified_triggers( + self: _ModelT, tree: dict[Field | None, Any], create: bool = ... + ) -> Iterator[tuple[Field, _ModelT, bool]]: ... + def recompute( + self, + fnames: Collection[str] | None = ..., + records: Union[BaseModel, None] = ..., + ) -> None: ... def _dependent_fields(self, field: Field) -> Iterator[Field]: ... def _has_onchange(self, field: Field, other_fields: Container[Field]) -> bool: ... def _onchange_spec(self, view_info: dict | None = ...) -> dict: ... def _onchange_eval(self, field_name: str, onchange: str, result: dict) -> None: ... - def onchange(self, values: dict[str, Any], field_name: str | list[str] | bool, field_onchange: dict[str, str]) -> dict: ... + def onchange( + self, + values: dict[str, Any], + field_name: str | list[str] | bool, + field_onchange: dict[str, str], + ) -> dict: ... class RecordCache(MutableMapping): _record: BaseModel @@ -341,9 +551,15 @@ class TransientModel(Model): _transient: bool def itemgetter_tuple(items) -> Callable[..., tuple]: ... -def convert_pgerror_not_null(model: BaseModel, fields: dict[str, dict[str, Any]], info, e: psycopg2.Error) -> dict[str, str]: ... -def convert_pgerror_unique(model: BaseModel, fields: dict[str, dict[str, Any]], info, e: psycopg2.Error) -> dict[str, str]: ... -def convert_pgerror_constraint(model: BaseModel, fields: dict[str, dict[str, Any]], info, e: psycopg2.Error) -> dict[str, str]: ... +def convert_pgerror_not_null( + model: BaseModel, fields: dict[str, dict[str, Any]], info, e: psycopg2.Error +) -> dict[str, str]: ... +def convert_pgerror_unique( + model: BaseModel, fields: dict[str, dict[str, Any]], info, e: psycopg2.Error +) -> dict[str, str]: ... +def convert_pgerror_constraint( + model: BaseModel, fields: dict[str, dict[str, Any]], info, e: psycopg2.Error +) -> dict[str, str]: ... PGERROR_TO_OE: dict[str, Callable] diff --git a/odoo-stubs/modules/__init__.pyi b/odoo-stubs/modules/__init__.pyi index 8fe50ad..e5edb0b 100644 --- a/odoo-stubs/modules/__init__.pyi +++ b/odoo-stubs/modules/__init__.pyi @@ -1,24 +1,20 @@ -from . import ( - db as db, - graph as graph, - loading as loading, - migration as migration, - module as module, - registry as registry -) -from .loading import ( - load_modules as load_modules, - reset_modules_state as reset_modules_state -) +from . import db as db +from . import graph as graph +from . import loading as loading +from . import migration as migration +from . import module as module +from . import registry as registry +from .loading import load_modules as load_modules +from .loading import reset_modules_state as reset_modules_state +from .module import adapt_version as adapt_version +from .module import get_module_path as get_module_path +from .module import get_module_resource as get_module_resource +from .module import get_modules as get_modules +from .module import get_modules_with_version as get_modules_with_version +from .module import get_resource_from_path as get_resource_from_path +from .module import get_resource_path as get_resource_path +from .module import initialize_sys_path as initialize_sys_path from .module import ( - adapt_version as adapt_version, - get_module_path as get_module_path, - get_module_resource as get_module_resource, - get_modules as get_modules, - get_modules_with_version as get_modules_with_version, - get_resource_from_path as get_resource_from_path, - get_resource_path as get_resource_path, - initialize_sys_path as initialize_sys_path, load_information_from_description_file as load_information_from_description_file, - load_openerp_module as load_openerp_module ) +from .module import load_openerp_module as load_openerp_module diff --git a/odoo-stubs/modules/graph.pyi b/odoo-stubs/modules/graph.pyi index fdc1933..429cfdc 100644 --- a/odoo-stubs/modules/graph.pyi +++ b/odoo-stubs/modules/graph.pyi @@ -6,7 +6,9 @@ class Graph(dict[str, Node]): def add_node(self, name: str, info: dict[str, Any]) -> Node: ... def update_from_db(self, cr: Cursor) -> None: ... def add_module(self, cr: Cursor, module: str, force: list | None = ...) -> None: ... - def add_modules(self, cr: Cursor, module_list: list[str], force: list | None = ...): ... + def add_modules( + self, cr: Cursor, module_list: list[str], force: list | None = ... + ): ... def __iter__(self) -> Iterator[Node]: ... def __str__(self) -> str: ... @@ -21,7 +23,9 @@ class Node: dbdemo: bool state: str installed_version: str - def __init__(self, name: str, graph: Graph, info: dict[str, Any] | None) -> None: ... + def __init__( + self, name: str, graph: Graph, info: dict[str, Any] | None + ) -> None: ... @property def data(self) -> dict[str, Any]: ... def add_child(self, name: str, info: dict[str, Any]): ... diff --git a/odoo-stubs/modules/loading.pyi b/odoo-stubs/modules/loading.pyi index 9e91be4..ff82f88 100644 --- a/odoo-stubs/modules/loading.pyi +++ b/odoo-stubs/modules/loading.pyi @@ -1,17 +1,51 @@ from typing import Any, Iterable +from ..sql_db import Connection, Cursor +from ..tools.assertion_report import assertion_report from .graph import Graph, Node from .registry import Registry -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: ... -def load_demo(cr: Cursor, package: Node, idref: dict, mode: str, report: assertion_report | None = ...) -> bool: ... +def load_data( + cr: Cursor, + idref: dict, + mode: str, + kind: str, + package: Node, + report: assertion_report, +) -> bool: ... +def load_demo( + cr: Cursor, + package: Node, + idref: dict, + mode: str, + report: assertion_report | None = ..., +) -> bool: ... def force_demo(cr: Cursor) -> None: ... -def load_module_graph(cr: Cursor, graph: Graph, status: Any | None = ..., perform_checks: Any = ..., skip_modules: list[str] | None = ..., - report: assertion_report | None = ..., models_to_check: set[str] | None = ...) -> tuple[list[str], list[str]]: ... +def load_module_graph( + cr: Cursor, + graph: Graph, + status: Any | None = ..., + perform_checks: Any = ..., + skip_modules: list[str] | None = ..., + report: assertion_report | None = ..., + models_to_check: set[str] | None = ..., +) -> tuple[list[str], list[str]]: ... 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: Connection, force_demo: bool = ..., status: Any | None = ..., update_module: Any = ...) -> Registry | 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: 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/migration.pyi b/odoo-stubs/modules/migration.pyi index 22b1740..9eb5a72 100644 --- a/odoo-stubs/modules/migration.pyi +++ b/odoo-stubs/modules/migration.pyi @@ -1,7 +1,7 @@ from types import ModuleType -from .graph import Graph, Node from ..sql_db import Cursor +from .graph import Graph, Node def load_script(path: str, module_name: str) -> ModuleType: ... diff --git a/odoo-stubs/modules/module.pyi b/odoo-stubs/modules/module.pyi index f452f09..258b313 100644 --- a/odoo-stubs/modules/module.pyi +++ b/odoo-stubs/modules/module.pyi @@ -1,6 +1,6 @@ import unittest from types import ModuleType -from typing import Any, Literal, MutableSequence, Generator +from typing import Any, Generator, Literal, MutableSequence MANIFEST_NAMES: tuple[str, ...] README: list[str] @@ -22,16 +22,21 @@ class UpgradeHook: def load_module(self, name: str) -> ModuleType | None: ... def initialize_sys_path() -> None: ... -def get_module_path(module: str, downloaded: bool = ..., display_warning: bool = ...) -> str | Literal[False]: ... +def get_module_path( + module: str, downloaded: bool = ..., display_warning: bool = ... +) -> str | Literal[False]: ... def get_module_filetree(module: str, dir: str = ...) -> dict: ... def get_resource_path(module: str, *args) -> str | Literal[False]: ... + get_module_resource = get_resource_path def get_resource_from_path(path: str) -> tuple[str, str, str] | None: ... def get_module_icon(module: str) -> str: ... def module_manifest(path: str) -> str | None: ... def get_module_root(path: str) -> str | None: ... -def load_information_from_description_file(module: str, mod_path: str | None = ...) -> dict: ... +def load_information_from_description_file( + module: str, mod_path: str | None = ... +) -> dict: ... def load_openerp_module(module_name: str) -> None: ... def get_modules() -> list[str]: ... def get_modules_with_version() -> dict[str, Any]: ... @@ -41,7 +46,17 @@ def _get_tests_modules(path: str, module: str) -> list: ... def _get_upgrade_test_modules(module) -> Generator[ModuleType, None, None]: ... class OdooTestResult(unittest.result.TestResult): - def log(self, level, msg, *args, test: Any | None = ..., exc_info: Any | None = ..., extra: Any | None = ..., stack_info: bool = ..., caller_infos: Any | None = ...) -> None: ... + def log( + self, + level, + msg, + *args, + test: Any | None = ..., + exc_info: Any | None = ..., + extra: Any | None = ..., + stack_info: bool = ..., + caller_infos: Any | None = ... + ) -> None: ... def getDescription(self, test): ... def startTest(self, test) -> None: ... def addError(self, test, err) -> None: ... diff --git a/odoo-stubs/modules/registry.pyi b/odoo-stubs/modules/registry.pyi index 98ac2db..c8a9d84 100644 --- a/odoo-stubs/modules/registry.pyi +++ b/odoo-stubs/modules/registry.pyi @@ -5,11 +5,11 @@ from threading import RLock from typing import Any, Callable, ClassVar, Iterable, Iterator from weakref import WeakValueDictionary -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 +from .graph import Node class Registry(Mapping[str, type[BaseModel]]): _lock: RLock @@ -18,7 +18,13 @@ class Registry(Mapping[str, type[BaseModel]]): registries: ClassVar[LRU] def __new__(cls, db_name: str) -> Registry: ... @classmethod - def new(cls, db_name: str, force_demo: bool = ..., status: Any | None = ..., update_module: bool = ...) -> Registry: ... + 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 @@ -58,7 +64,9 @@ class Registry(Mapping[str, type[BaseModel]]): def post_constraint(self, func: Callable, *args, **kwargs) -> None: ... def finalize_constraints(self) -> None: ... _is_install: bool - def init_models(self, cr: Cursor, model_names: Iterable[str], context: dict, install: bool = ...) -> None: ... + 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: ... diff --git a/odoo-stubs/netsvc.pyi b/odoo-stubs/netsvc.pyi index c40e26d..c8b5454 100644 --- a/odoo-stubs/netsvc.pyi +++ b/odoo-stubs/netsvc.pyi @@ -1,7 +1,9 @@ import logging.handlers from logging import Logger, LogRecord -def log(logger: Logger, level: int, prefix: str, msg, depth: int | None = ...) -> None: ... +def log( + logger: Logger, level: int, prefix: str, msg, depth: int | None = ... +) -> None: ... class PostgreSQLHandler(logging.Handler): def emit(self, record: LogRecord) -> None: ... @@ -23,11 +25,15 @@ COLOR_PATTERN: str LEVEL_COLOR_MAPPING: dict[int, tuple[int, int]] class PerfFilter(logging.Filter): - def format_perf(self, query_count: int, query_time: float, remaining_time: float): ... + def format_perf( + self, query_count: int, query_time: float, remaining_time: float + ): ... def filter(self, record: LogRecord): ... class ColoredPerfFilter(PerfFilter): - def format_perf(self, query_count: int, query_time: float, remaining_time: float): ... + def format_perf( + self, query_count: int, query_time: float, remaining_time: float + ): ... class DBFormatter(logging.Formatter): def format(self, record: LogRecord): ... diff --git a/odoo-stubs/osv/expression.pyi b/odoo-stubs/osv/expression.pyi index eab8ce2..6a73469 100644 --- a/odoo-stubs/osv/expression.pyi +++ b/odoo-stubs/osv/expression.pyi @@ -1,7 +1,8 @@ from functools import partial as partial from typing import Any, Callable -from ..models import BaseModel, MAGIC_COLUMNS as MAGIC_COLUMNS +from ..models import MAGIC_COLUMNS as MAGIC_COLUMNS +from ..models import BaseModel from ..sql_db import Cursor from ..tools.misc import get_lang as get_lang @@ -28,13 +29,24 @@ def OR(domains: list[_Domain]) -> _Domain: ... def distribute_not(domain: _Domain) -> _Domain: ... def _quote(to_quote: str) -> str: ... def _shorten_alias(alias: str) -> str: ... -def generate_table_alias(src_table_alias: str, joined_tables: list = ...) -> tuple[str, str]: ... +def generate_table_alias( + src_table_alias: str, joined_tables: list = ... +) -> tuple[str, str]: ... def get_alias_from_query(from_query: str) -> tuple[str, str]: ... def normalize_leaf(element): ... def is_operator(element) -> bool: ... def is_leaf(element, internal: bool = ...) -> bool: ... -def select_from_where(cr: Cursor, select_field: str, from_table: str, where_field: str, where_ids: list[int], where_operator: str) -> list: ... -def select_distinct_from_where_not_null(cr: Cursor, select_field: str, from_table: str) -> list: ... +def select_from_where( + cr: Cursor, + select_field: str, + from_table: str, + where_field: str, + where_ids: list[int], + where_operator: str, +) -> list: ... +def select_distinct_from_where_not_null( + cr: Cursor, select_field: str, from_table: str +) -> list: ... def get_unaccent_wrapper(cr: Cursor) -> Callable[[Any], str]: ... class ExtendedLeaf: @@ -42,7 +54,13 @@ class ExtendedLeaf: leaf: Any model: BaseModel _models: list[BaseModel] - def __init__(self, leaf, model: BaseModel, join_context: list[tuple] | None = ..., internal: bool = ...) -> None: ... + def __init__( + self, + leaf, + model: BaseModel, + join_context: list[tuple] | None = ..., + internal: bool = ..., + ) -> None: ... def __str__(self) -> str: ... def generate_alias(self) -> str: ... def add_join_context(self, model, lhs_col, table_col, link) -> None: ... @@ -56,7 +74,12 @@ class ExtendedLeaf: def is_leaf(self, internal: bool = ...): ... def normalize_leaf(self) -> bool: ... -def create_substitution_leaf(leaf: ExtendedLeaf, new_elements, new_model: BaseModel | None = ..., internal: bool = ...) -> ExtendedLeaf: ... +def create_substitution_leaf( + leaf: ExtendedLeaf, + new_elements, + new_model: BaseModel | None = ..., + internal: bool = ..., +) -> ExtendedLeaf: ... class expression: _unaccent: Callable[[Any], str] diff --git a/odoo-stubs/osv/query.pyi b/odoo-stubs/osv/query.pyi index b5d2f88..4e65320 100644 --- a/odoo-stubs/osv/query.pyi +++ b/odoo-stubs/osv/query.pyi @@ -6,9 +6,23 @@ class Query: where_clause_params: list = ... joins: dict = ... extras: dict = ... - def __init__(self, tables: list[str] | None = ..., where_clause: list | None = ..., where_clause_params: list | None = ..., joins: dict | None = ..., extras: dict | None = ...) -> None: ... + def __init__( + self, + tables: list[str] | None = ..., + where_clause: list | None = ..., + where_clause_params: list | None = ..., + joins: dict | None = ..., + extras: dict | None = ..., + ) -> None: ... def _get_table_aliases(self) -> list: ... def _get_alias_mapping(self) -> dict: ... - def add_join(self, connection: tuple, implicit: bool = ..., outer: bool = ..., extra: str | None = ..., extra_params: list = ...): ... + def add_join( + self, + connection: tuple, + implicit: bool = ..., + outer: bool = ..., + extra: str | None = ..., + extra_params: list = ..., + ): ... def get_sql(self) -> str: ... def __str__(self) -> str: ... diff --git a/odoo-stubs/service/__init__.pyi b/odoo-stubs/service/__init__.pyi index a2984f7..2d4b73d 100644 --- a/odoo-stubs/service/__init__.pyi +++ b/odoo-stubs/service/__init__.pyi @@ -1 +1,5 @@ -from . import common as common, db as db, model as model, server as server, wsgi_server as wsgi_server +from . import common as common +from . import db as db +from . import model as model +from . import server as server +from . import wsgi_server as wsgi_server diff --git a/odoo-stubs/service/common.pyi b/odoo-stubs/service/common.pyi index a8c347a..13d77d7 100644 --- a/odoo-stubs/service/common.pyi +++ b/odoo-stubs/service/common.pyi @@ -4,7 +4,9 @@ from typing import Any, Literal RPC_VERSION_1: dict[str, Any] def exp_login(db: str, login: str, password: str) -> int: ... -def exp_authenticate(db: str, login: str, password: str, user_agent_env: dict | None) -> int: ... +def exp_authenticate( + db: str, login: str, password: str, user_agent_env: dict | None +) -> int: ... def exp_version() -> dict[str, Any]: ... def exp_about(extended: bool = ...) -> str | tuple[str, str]: ... def exp_set_loglevel(loglevel, logger: Logger | None = ...) -> Literal[True]: ... diff --git a/odoo-stubs/service/db.pyi b/odoo-stubs/service/db.pyi index 5e64ad9..30c239d 100644 --- a/odoo-stubs/service/db.pyi +++ b/odoo-stubs/service/db.pyi @@ -1,19 +1,34 @@ from functools import wraps as wraps -from typing import Any, Callable, IO, Iterable, Literal, TypeVar +from typing import IO, Any, Callable, Iterable, Literal, TypeVar from ..sql_db import Cursor -_CallableT = TypeVar('_CallableT', bound=Callable) +_CallableT = TypeVar("_CallableT", bound=Callable) class DatabaseExists(Warning): ... def check_db_management_enabled(method: _CallableT) -> _CallableT: ... def check_super(passwd: str) -> Literal[True]: ... -def _initialize_db(id, db_name: str, demo: bool, lang: str, user_password: str, login: str = ..., - country_code: str | None = ..., phone: str | None = ...) -> None: ... +def _initialize_db( + id, + db_name: str, + demo: bool, + lang: str, + user_password: str, + login: str = ..., + country_code: str | None = ..., + phone: str | None = ..., +) -> None: ... def _create_empty_database(name: str) -> None: ... -def exp_create_database(db_name: str, demo: bool, lang: str, user_password: str = ..., login: str = ..., - country_code: str | None = ..., phone: str | None = ...) -> Literal[True]: ... +def exp_create_database( + db_name: str, + demo: bool, + lang: str, + user_password: str = ..., + login: str = ..., + country_code: str | None = ..., + phone: str | None = ..., +) -> Literal[True]: ... def exp_duplicate_database(db_original_name: str, db_name: str) -> Literal[True]: ... def _drop_conn(cr: Cursor, db_name: str) -> None: ... def exp_drop(db_name: str) -> bool: ... diff --git a/odoo-stubs/service/model.pyi b/odoo-stubs/service/model.pyi index 9c8e35e..edbecc5 100644 --- a/odoo-stubs/service/model.pyi +++ b/odoo-stubs/service/model.pyi @@ -5,10 +5,12 @@ from ..sql_db import Cursor PG_CONCURRENCY_ERRORS_TO_RETRY: tuple[str, str, str] MAX_TRIES_ON_CONCURRENCY_FAILURE: int -_CallableT = TypeVar('_CallableT', bound=Callable) +_CallableT = TypeVar("_CallableT", bound=Callable) def dispatch(method: str, params): ... def check(f: _CallableT) -> _CallableT: ... def execute_cr(cr: Cursor, uid: int, obj: str, method: str, *args, **kw): ... -def execute_kw(db: str, uid: int, obj: str, method: str, args, kw: dict | None = ...): ... +def execute_kw( + db: str, uid: int, obj: str, method: str, args, kw: dict | None = ... +): ... def execute(db: str, uid: int, obj: str, method: str, *args, **kw): ... diff --git a/odoo-stubs/service/security.pyi b/odoo-stubs/service/security.pyi index 4432c6c..f89dc35 100644 --- a/odoo-stubs/service/security.pyi +++ b/odoo-stubs/service/security.pyi @@ -5,5 +5,7 @@ from ..http import OpenERPSession def login(db: str, login: str, password: str) -> int | Literal[False]: ... def check(db: str, uid: int, passwd: str) -> None: ... -def compute_session_token(session: OpenERPSession, env: Environment) -> str | Literal[False]: ... +def compute_session_token( + session: OpenERPSession, env: Environment +) -> str | Literal[False]: ... def check_session(session: OpenERPSession, env: Environment) -> bool: ... diff --git a/odoo-stubs/service/server.pyi b/odoo-stubs/service/server.pyi index 06b2b17..96de13d 100644 --- a/odoo-stubs/service/server.pyi +++ b/odoo-stubs/service/server.pyi @@ -1,11 +1,10 @@ +from itertools import chain as chain from socket import socket as socket_ from threading import Semaphore, Thread - -from gevent.pywsgi import WSGIServer -from itertools import chain as chain from typing import Any, Callable, Iterable, Literal, TypeVar import werkzeug.serving +from gevent.pywsgi import WSGIServer from inotify.adapters import InotifyTrees from psutil import Process from watchdog.observers import Observer @@ -14,7 +13,7 @@ from ..modules.registry import Registry from ..sql_db import Cursor from ..tests import runner as runner -_WorkerT = TypeVar('_WorkerT', bound=Worker) +_WorkerT = TypeVar("_WorkerT", bound=Worker) INOTIFY_LISTEN_EVENTS: Any SLEEP_INTERVAL: int @@ -33,7 +32,9 @@ class BaseWSGIServerNoBind(LoggingBaseWSGIServerMixIn, werkzeug.serving.BaseWSGI class RequestHandler(werkzeug.serving.WSGIRequestHandler): def setup(self) -> None: ... -class ThreadedWSGIServerReloadable(LoggingBaseWSGIServerMixIn, werkzeug.serving.ThreadedWSGIServer): +class ThreadedWSGIServerReloadable( + LoggingBaseWSGIServerMixIn, werkzeug.serving.ThreadedWSGIServer +): max_http_threads: Any http_threads_sem: Semaphore daemon_threads: bool @@ -123,7 +124,9 @@ class PreforkServer(CommonServer): def pipe_new(self) -> tuple[int, int]: ... def pipe_ping(self, pipe: tuple[int, int]) -> None: ... def signal_handler(self, sig: int, frame) -> None: ... - def worker_spawn(self, klass: Callable[..., _WorkerT], workers_registry: dict[int, _WorkerT]) -> _WorkerT | None: ... + def worker_spawn( + self, klass: Callable[..., _WorkerT], workers_registry: dict[int, _WorkerT] + ) -> _WorkerT | None: ... def long_polling_spawn(self) -> None: ... def worker_pop(self, pid: int) -> None: ... def worker_kill(self, pid: int, sig: int) -> None: ... diff --git a/odoo-stubs/service/wsgi_server.pyi b/odoo-stubs/service/wsgi_server.pyi index 8cb4e31..9199e6e 100644 --- a/odoo-stubs/service/wsgi_server.pyi +++ b/odoo-stubs/service/wsgi_server.pyi @@ -1,6 +1,7 @@ -from werkzeug.middleware.proxy_fix import ProxyFix as ProxyFix_ from typing import Callable +from werkzeug.middleware.proxy_fix import ProxyFix as ProxyFix_ + RPC_FAULT_CODE_CLIENT_ERROR: int RPC_FAULT_CODE_APPLICATION_ERROR: int RPC_FAULT_CODE_WARNING: int diff --git a/odoo-stubs/sql_db.pyi b/odoo-stubs/sql_db.pyi index c6f603e..24c7d60 100644 --- a/odoo-stubs/sql_db.pyi +++ b/odoo-stubs/sql_db.pyi @@ -1,12 +1,22 @@ from re import Pattern from threading import Lock, RLock -from typing import Any, Callable, Iterable, Iterator, Literal, NoReturn, Sequence, TypeVar, Generator +from typing import ( + Any, + Callable, + Generator, + Iterable, + Iterator, + Literal, + NoReturn, + Sequence, + TypeVar, +) import psycopg2.extensions -_T = TypeVar('_T') -_CallableT = TypeVar('_CallableT', bound=Callable) -_CursorT = TypeVar('_CursorT', bound=Cursor) +_T = TypeVar("_T") +_CallableT = TypeVar("_CallableT", bound=Callable) +_CursorT = TypeVar("_CursorT", bound=Cursor) def unbuffer(symb, cr) -> str | None: ... def undecimalize(symb, cr) -> float | None: ... @@ -36,14 +46,20 @@ class Cursor: _default_log_exceptions: bool cache: dict _event_handlers: dict[str, list[Callable]] - def __init__(self, pool: ConnectionPool, dbname: str, dsn: dict, serialized: bool = ...) -> None: ... + def __init__( + self, pool: ConnectionPool, dbname: str, dsn: dict, serialized: bool = ... + ) -> None: ... def __build_dict(self, row: Sequence) -> dict[str, Any]: ... def dictfetchone(self) -> dict[str, Any] | None: ... def dictfetchmany(self, size) -> list[dict[str, Any]]: ... def dictfetchall(self) -> list[dict[str, Any]]: ... def __del__(self) -> None: ... - def execute(self, query, params: Any | None = ..., log_exceptions: Any | None = ...): ... - def split_for_in_conditions(self, ids: Iterable, size: int | None = ...) -> Iterator[tuple]: ... + def execute( + self, query, params: Any | None = ..., log_exceptions: Any | None = ... + ): ... + def split_for_in_conditions( + self, ids: Iterable, size: int | None = ... + ) -> Iterator[tuple]: ... def print_log(self): ... def close(self): ... def _close(self, leak: bool = ...) -> None: ... @@ -85,7 +101,9 @@ class ConnectionPool: def __repr__(self) -> str: ... def _debug(self, msg, *args) -> None: ... def borrow(self, connection_info: dict) -> PsycoConnection: ... - def give_back(self, connection: PsycoConnection, keep_in_pool: bool = ...) -> None: ... + def give_back( + self, connection: PsycoConnection, keep_in_pool: bool = ... + ) -> None: ... def close_all(self, dsn: dict | None = ...) -> None: ... class Connection: diff --git a/odoo-stubs/tests/__init__.pyi b/odoo-stubs/tests/__init__.pyi index fabbb63..94007b2 100644 --- a/odoo-stubs/tests/__init__.pyi +++ b/odoo-stubs/tests/__init__.pyi @@ -1,2 +1,2 @@ -from .common import * from . import common as common +from .common import * diff --git a/odoo-stubs/tests/common.pyi b/odoo-stubs/tests/common.pyi index 153b103..b249f82 100644 --- a/odoo-stubs/tests/common.pyi +++ b/odoo-stubs/tests/common.pyi @@ -1,10 +1,19 @@ import collections import logging import unittest -from re import Pattern - from itertools import count -from typing import Any, Callable, Generator, Generic, Iterator, Literal, Mapping, Match, TypeVar +from re import Pattern +from typing import ( + Any, + Callable, + Generator, + Generic, + Iterator, + Literal, + Mapping, + Match, + TypeVar, +) from xmlrpc import client as xmlrpclib import requests @@ -17,10 +26,10 @@ from ..models import BaseModel from ..modules.registry import Registry from ..sql_db import Cursor -_T = TypeVar('_T') -_CallableT = TypeVar('_CallableT', bound=Callable) -_ModelT = TypeVar('_ModelT', bound=BaseModel) -_FormT = TypeVar('_FormT', bound=Form) +_T = TypeVar("_T") +_CallableT = TypeVar("_CallableT", bound=Callable) +_ModelT = TypeVar("_ModelT", bound=BaseModel) +_FormT = TypeVar("_FormT", bound=Form) ADDONS_PATH: str HOST: str @@ -29,15 +38,25 @@ ADMIN_USER_ID: int def get_db_name() -> str: ... DB: str + def at_install(flag): ... def post_install(flag): ... - -def new_test_user(env: Environment, login: str = ..., groups: str = ..., context: dict | None = ..., **kwargs) -> 'odoo.model.res_users': ... +def new_test_user( + env: Environment, + login: str = ..., + groups: str = ..., + context: dict | None = ..., + **kwargs +) -> "odoo.model.res_users": ... class OdooSuite(unittest.suite.TestSuite): def _handleClassSetUp(self, test, result) -> None: ... - def _createClassOrModuleLevelException(self, result, exc, method_name, parent, info: Any | None = ...) -> None: ... - def _addClassOrModuleLevelException(self, result, exception, errorName, info: Any | None = ...) -> None: ... + def _createClassOrModuleLevelException( + self, result, exc, method_name, parent, info: Any | None = ... + ) -> None: ... + def _addClassOrModuleLevelException( + self, result, exception, errorName, info: Any | None = ... + ) -> None: ... def _tearDownPreviousClass(self, test, result) -> None: ... class TreeCase(unittest.TestCase): @@ -72,9 +91,15 @@ class BaseCase(TreeCase): def ref(self, xid: str) -> int: ... def browse_ref(self, xid: str) -> BaseModel | None: ... def _assertRaises(self, exception) -> Generator[Any, None, None]: ... - def assertRaises(self, exception, func: Any | None = ..., *args, **kwargs) -> Generator[Any, None, None] | None: ... - def assertQueryCount(self, default: int = ..., flush: bool = ..., **counters) -> Generator[None, None, None]: ... - def assertRecordValues(self, records: BaseModel, expected_values: list[dict[str, Any]]) -> None: ... + def assertRaises( + self, exception, func: Any | None = ..., *args, **kwargs + ) -> Generator[Any, None, None] | None: ... + def assertQueryCount( + self, default: int = ..., flush: bool = ..., **counters + ) -> Generator[None, None, None]: ... + def assertRecordValues( + self, records: BaseModel, expected_values: list[dict[str, Any]] + ) -> None: ... def shortDescription(self) -> None: ... def assertItemsEqual(self, a, b, msg: str | None = ...) -> None: ... @@ -112,7 +137,9 @@ class ChromeBrowser: screencast_frames: list window_size: str sigxcpu_handler: Any - def __init__(self, logger: logging.Logger, window_size: str, test_class: str) -> None: ... + def __init__( + self, logger: logging.Logger, window_size: str, test_class: str + ) -> None: ... def signal_handler(self, sig, frame) -> None: ... def stop(self) -> None: ... @property @@ -120,13 +147,17 @@ class ChromeBrowser: def _spawn_chrome(self, cmd: list[str]) -> int | None: ... def _chrome_start(self) -> None: ... def _find_websocket(self) -> None: ... - def _json_command(self, command: str, timeout: int = ..., get_key: Any | None = ...): ... + def _json_command( + self, command: str, timeout: int = ..., get_key: Any | None = ... + ): ... def _open_websocket(self) -> None: ... def _websocket_send(self, method: str, params: Any | None = ...) -> int | None: ... def _get_message(self, raise_log_error: bool = ...) -> dict: ... _TO_LEVEL: dict[str, int] def _websocket_wait_id(self, awaited_id: int, timeout: int = ...) -> dict: ... - def _websocket_wait_event(self, method: str, params: dict | None = ..., timeout: int = ...) -> dict | None: ... + def _websocket_wait_event( + self, method: str, params: dict | None = ..., timeout: int = ... + ) -> dict | None: ... def take_screenshot(self, prefix: str = ..., suffix: str | None = ...) -> None: ... def _save_screencast(self, prefix: str = ...) -> None: ... screencasts_frames_dir: str @@ -160,13 +191,29 @@ class HttpCase(TransactionCase): session_id: Any opener: requests.Session def setUp(self) -> None: ... - def url_open(self, url: str, data: Any | None = ..., files: Mapping | None = ..., timeout: int = ..., - headers: Mapping | None = ...) -> requests.Response: ... + def url_open( + self, + url: str, + data: Any | None = ..., + files: Mapping | None = ..., + timeout: int = ..., + headers: Mapping | None = ..., + ) -> requests.Response: ... def _wait_remaining_requests(self, timeout: int = ...) -> None: ... def logout(self, keep_db: bool = ...) -> None: ... def authenticate(self, user, password) -> None: ... - def browser_js(self, url_path: str, code: str, ready: str = ..., login: str | None = ..., timeout: int = ..., **kw) -> None: ... - def start_tour(self, url_path: str, tour_name: str, step_delay: float | None = ..., **kwargs) -> None: ... + def browser_js( + self, + url_path: str, + code: str, + ready: str = ..., + login: str | None = ..., + timeout: int = ..., + **kw + ) -> None: ... + def start_tour( + self, url_path: str, tour_name: str, step_delay: float | None = ..., **kwargs + ) -> None: ... phantom_js = browser_js def users(*logins: str) -> Callable[[_CallableT], _CallableT]: ... @@ -182,14 +229,24 @@ class Form(Generic[_ModelT]): _values: dict _changed: set def __init__(self, recordp: _ModelT, view: _ModelT | str | None = ...) -> None: ... - def _o2m_set_edition_view(self, descr: dict, node: _Element, level: int) -> None: ... + def _o2m_set_edition_view( + self, descr: dict, node: _Element, level: int + ) -> None: ... def __str__(self) -> str: ... def _process_fvg(self, model: BaseModel, fvg: dict, level: int = ...) -> None: ... def _init_from_defaults(self, model: BaseModel) -> None: ... def _init_from_values(self, values: BaseModel) -> None: ... def __getattr__(self, field: str): ... - def _get_modifier(self, field: str, modifier: str, *, default: Any = ..., view: Any = ..., modmap: Any | None = ..., - vals: Any | None = ...): ... + def _get_modifier( + self, + field: str, + modifier: str, + *, + default: Any = ..., + view: Any = ..., + modmap: Any | None = ..., + vals: Any | None = ... + ): ... _OPS: dict[str, Callable[..., bool]] def _get_context(self, field: str): ... def __setattr__(self, field: str, value) -> None: ... @@ -197,8 +254,16 @@ class Form(Generic[_ModelT]): def __exit__(self, etype, _evalue, _etb) -> None: ... def save(self) -> _ModelT: ... def _values_to_save(self, all_fields: bool = ...) -> dict: ... - def _values_to_save_(self, record_values: dict, fields: dict, view: Any, changed: set, all_fields: bool = ..., - modifiers_values: dict | None = ..., parent_link: Any | None = ...) -> dict: ... + def _values_to_save_( + self, + record_values: dict, + fields: dict, + view: Any, + changed: set, + all_fields: bool = ..., + modifiers_values: dict | None = ..., + parent_link: Any | None = ..., + ) -> dict: ... def _perform_onchange(self, fields: list[str]) -> None: ... def _onchange_values(self) -> dict: ... def _onchange_values_(self, fields, record: dict) -> dict: ... @@ -208,8 +273,16 @@ class O2MForm(Form): _proxy: O2MProxy _index: int | None def __init__(self, proxy: O2MProxy, index: int | None = ...) -> None: ... - def _get_modifier(self, field: str, modifier: str, *, default: Any = ..., view: Any = ..., modmap: Any | None = ..., - vals: Any | None = ...): ... + def _get_modifier( + self, + field: str, + modifier: str, + *, + default: Any = ..., + view: Any = ..., + modmap: Any | None = ..., + vals: Any | None = ... + ): ... def _onchange_values(self) -> dict: ... def save(self) -> None: ... def _values_to_save(self, all_fields: bool = ...) -> UpdateDict: ... diff --git a/odoo-stubs/tools/__init__.pyi b/odoo-stubs/tools/__init__.pyi index 70aaa51..3623097 100644 --- a/odoo-stubs/tools/__init__.pyi +++ b/odoo-stubs/tools/__init__.pyi @@ -1,15 +1,18 @@ -from .misc import * -from .translate import * -from .image import * -from .sql import * -from .float_utils import * -from .mail import * -from .func import * -from .debugger import * -from .xml_utils import * -from .date_utils import * -from .convert import * -from .template_inheritance import * -from . import appdirs as appdirs, cloc as cloc, pdf as pdf, pycompat as pycompat +from . import appdirs as appdirs +from . import cloc as cloc +from . import pdf as pdf +from . import pycompat as pycompat from .config import config as config +from .convert import * +from .date_utils import * +from .debugger import * +from .float_utils import * +from .func import * from .graph import graph as graph +from .image import * +from .mail import * +from .misc import * +from .sql import * +from .template_inheritance import * +from .translate import * +from .xml_utils import * diff --git a/odoo-stubs/tools/appdirs.pyi b/odoo-stubs/tools/appdirs.pyi index 0b6cd4b..c06bd7b 100644 --- a/odoo-stubs/tools/appdirs.pyi +++ b/odoo-stubs/tools/appdirs.pyi @@ -3,12 +3,42 @@ from typing import Callable __version_info__: tuple __version__: str -def user_data_dir(appname: str | None = ..., appauthor: str | None = ..., version: str | None = ..., roaming: bool = ...) -> str: ... -def site_data_dir(appname: str | None = ..., appauthor: str | None = ..., version: str | None = ..., multipath: bool = ...) -> str: ... -def user_config_dir(appname: str | None = ..., appauthor: str | None = ..., version: str | None = ..., roaming: bool = ...) -> str: ... -def site_config_dir(appname: str | None = ..., appauthor: str | None = ..., version: str | None = ..., multipath: bool = ...) -> str: ... -def user_cache_dir(appname: str | None = ..., appauthor: str | None = ..., version: str | None = ..., opinion: bool = ...) -> str: ... -def user_log_dir(appname: str | None = ..., appauthor: str | None = ..., version: str | None = ..., opinion: bool = ...) -> str: ... +def user_data_dir( + appname: str | None = ..., + appauthor: str | None = ..., + version: str | None = ..., + roaming: bool = ..., +) -> str: ... +def site_data_dir( + appname: str | None = ..., + appauthor: str | None = ..., + version: str | None = ..., + multipath: bool = ..., +) -> str: ... +def user_config_dir( + appname: str | None = ..., + appauthor: str | None = ..., + version: str | None = ..., + roaming: bool = ..., +) -> str: ... +def site_config_dir( + appname: str | None = ..., + appauthor: str | None = ..., + version: str | None = ..., + multipath: bool = ..., +) -> str: ... +def user_cache_dir( + appname: str | None = ..., + appauthor: str | None = ..., + version: str | None = ..., + opinion: bool = ..., +) -> str: ... +def user_log_dir( + appname: str | None = ..., + appauthor: str | None = ..., + version: str | None = ..., + opinion: bool = ..., +) -> str: ... class AppDirs: appname: str @@ -16,7 +46,14 @@ class AppDirs: version: str | None roaming: bool multipath: bool - def __init__(self, appname: str, appauthor: str | None = ..., version: str | None = ..., roaming: bool = ..., multipath: bool = ...) -> None: ... + def __init__( + self, + appname: str, + appauthor: str | None = ..., + version: str | None = ..., + roaming: bool = ..., + multipath: bool = ..., + ) -> None: ... @property def user_data_dir(self) -> str: ... @property @@ -33,4 +70,5 @@ class AppDirs: def _get_win_folder_from_registry(csidl_name: str) -> str: ... def _get_win_folder_with_pywin32(csidl_name: str) -> str: ... def _get_win_folder_with_ctypes(csidl_name: str) -> str: ... + _get_win_folder: Callable[[str], str] diff --git a/odoo-stubs/tools/cache.pyi b/odoo-stubs/tools/cache.pyi index 55b9495..c2ee8ce 100644 --- a/odoo-stubs/tools/cache.pyi +++ b/odoo-stubs/tools/cache.pyi @@ -1,11 +1,11 @@ from collections import defaultdict from typing import Any, Callable, TypeVar -from .lru import LRU from ..models import BaseModel +from .lru import LRU -_T = TypeVar('_T') -_CallableT = TypeVar('_CallableT') +_T = TypeVar("_T") +_CallableT = TypeVar("_CallableT") unsafe_eval = eval @@ -27,7 +27,9 @@ class ormcache: def __call__(self, method: _CallableT) -> _CallableT: ... key: Any def determine_key(self): ... - def lru(self, model: BaseModel) -> tuple[LRU, tuple[str, Callable], ormcache_counter]: ... + def lru( + self, model: BaseModel + ) -> tuple[LRU, tuple[str, Callable], ormcache_counter]: ... def lookup(self, method: Callable, *args, **kwargs): ... def clear(self, model: BaseModel, *args) -> None: ... @@ -52,4 +54,5 @@ class dummy_cache: def log_ormcache_stats(sig: Any | None = ..., frame: Any | None = ...): ... def get_cache_key_counter(bound_method, *args, **kwargs): ... + cache = ormcache diff --git a/odoo-stubs/tools/cloc.pyi b/odoo-stubs/tools/cloc.pyi index 11f94b7..7184760 100644 --- a/odoo-stubs/tools/cloc.pyi +++ b/odoo-stubs/tools/cloc.pyi @@ -19,7 +19,13 @@ class Cloc: def parse_xml(self, s: str) -> tuple[int, int]: ... def parse_py(self, s: str) -> tuple[int, int]: ... def parse_js(self, s: str) -> tuple[int, int]: ... - def book(self, module: str, item: str = ..., count: tuple[Any, Any] = ..., exclude: bool = ...) -> None: ... + def book( + self, + module: str, + item: str = ..., + count: tuple[Any, Any] = ..., + exclude: bool = ..., + ) -> None: ... def count_path(self, path: str, exclude: set[str] | None = ...) -> None: ... def count_modules(self, env: Environment) -> None: ... def count_customization(self, env: Environment) -> None: ... diff --git a/odoo-stubs/tools/config.pyi b/odoo-stubs/tools/config.pyi index 4f06edb..2ae7e17 100644 --- a/odoo-stubs/tools/config.pyi +++ b/odoo-stubs/tools/config.pyi @@ -27,10 +27,16 @@ class configmanager: rcfile: str def _parse_config(self, args: list | None = ...) -> None: ... def _is_addons_path(self, path: str) -> bool: ... - def _check_addons_path(self, option: MyOption, opt, value, parser: OptionParser) -> None: ... - def _check_upgrade_path(self, option: MyOption, opt, value, parser: OptionParser) -> None: ... + def _check_addons_path( + self, option: MyOption, opt, value, parser: OptionParser + ) -> None: ... + def _check_upgrade_path( + self, option: MyOption, opt, value, parser: OptionParser + ) -> None: ... def _is_upgrades_path(self, res: str) -> bool: ... - def _test_enable_callback(self, option: MyOption, opt, value, parser: OptionParser) -> None: ... + def _test_enable_callback( + self, option: MyOption, opt, value, parser: OptionParser + ) -> None: ... def load(self) -> None: ... def save(self) -> None: ... def get(self, key, default: Any | None = ...): ... diff --git a/odoo-stubs/tools/convert.pyi b/odoo-stubs/tools/convert.pyi index 6c9d117..327d19e 100644 --- a/odoo-stubs/tools/convert.pyi +++ b/odoo-stubs/tools/convert.pyi @@ -3,10 +3,10 @@ from typing import Any, Callable, TextIO from lxml.etree import _Element -from .assertion_report import assertion_report as AssertionReport -from .misc import ustr as ustr from ..api import Environment from ..sql_db import Cursor +from .assertion_report import assertion_report as AssertionReport +from .misc import ustr as ustr safe_eval: Callable @@ -30,7 +30,9 @@ def str2bool(value) -> bool: ... def nodeattr2bool(node: _Element, attr, default: bool = ...) -> bool: ... class xml_import: - def get_env(self, node: _Element, eval_context: dict | None = ...) -> Environment: ... + def get_env( + self, node: _Element, eval_context: dict | None = ... + ) -> Environment: ... def make_xml_id(self, xml_id: str) -> str: ... def _test_xml_id(self, xml_id: str) -> None: ... def _tag_delete(self, rec: _Element) -> None: ... @@ -41,7 +43,9 @@ class xml_import: def _tag_record(self, rec: _Element) -> tuple[str, int] | None: ... def _tag_template(self, el: _Element) -> tuple[str, int] | None: ... def id_get(self, id_str: str, raise_if_not_found: bool = ...) -> int | None: ... - def model_id_get(self, id_str: str, raise_if_not_found: bool = ...) -> tuple[Any, Any]: ... + def model_id_get( + self, id_str: str, raise_if_not_found: bool = ... + ) -> tuple[Any, Any]: ... def _tag_root(self, el: _Element) -> None: ... @property def env(self) -> Environment: ... @@ -55,11 +59,46 @@ class xml_import: _noupdate: list[bool] xml_filename: str _tags: dict[str, Callable] - def __init__(self, cr: Cursor, module: str, idref: dict, mode: str, report: AssertionReport | None = ..., noupdate: bool = ..., xml_filename: str | None = ...) -> None: ... + def __init__( + self, + cr: Cursor, + module: str, + idref: dict, + mode: str, + report: AssertionReport | None = ..., + noupdate: bool = ..., + xml_filename: str | None = ..., + ) -> None: ... def parse(self, de: _Element) -> None: ... DATA_ROOTS: list[str] -def convert_file(cr: Cursor, module: str, filename: str, idref: dict, mode: str = ..., noupdate: bool = ..., kind: str | None = ..., report: Any | None = ..., pathname: str | None = ...) -> None: ... +def convert_file( + cr: Cursor, + module: str, + filename: str, + idref: dict, + mode: str = ..., + noupdate: bool = ..., + kind: str | None = ..., + report: Any | None = ..., + pathname: str | None = ..., +) -> None: ... def convert_sql_import(cr: Cursor, fp: TextIO) -> None: ... -def convert_csv_import(cr: Cursor, module: str, fname: str, csvcontent: bytes, idref: dict | None = ..., mode: str = ..., noupdate: bool = ...) -> None: ... -def convert_xml_import(cr: Cursor, module: str, xmlfile: str | BufferedReader, idref: dict | None = ..., mode: str = ..., noupdate: bool = ..., report: Any | None = ...) -> None: ... +def convert_csv_import( + cr: Cursor, + module: str, + fname: str, + csvcontent: bytes, + idref: dict | None = ..., + mode: str = ..., + noupdate: bool = ..., +) -> None: ... +def convert_xml_import( + cr: Cursor, + module: str, + xmlfile: str | BufferedReader, + idref: dict | None = ..., + mode: str = ..., + noupdate: bool = ..., + report: Any | None = ..., +) -> None: ... diff --git a/odoo-stubs/tools/date_utils.pyi b/odoo-stubs/tools/date_utils.pyi index bbf8cc2..d7bef90 100644 --- a/odoo-stubs/tools/date_utils.pyi +++ b/odoo-stubs/tools/date_utils.pyi @@ -1,18 +1,22 @@ import datetime -from typing import Tuple, Iterator, TypeVar +from typing import Iterator, Tuple, TypeVar from dateutil.relativedelta import relativedelta -_DateTimeT = TypeVar('_DateTimeT', datetime.date, datetime.datetime) +_DateTimeT = TypeVar("_DateTimeT", datetime.date, datetime.datetime) def get_month(date: _DateTimeT) -> Tuple[_DateTimeT, _DateTimeT]: ... def get_quarter_number(date: _DateTimeT) -> int: ... def get_quarter(date: _DateTimeT) -> Tuple[_DateTimeT, _DateTimeT]: ... -def get_fiscal_year(date: _DateTimeT, day: int = ..., month: int = ...) -> Tuple[_DateTimeT, _DateTimeT]: ... +def get_fiscal_year( + date: _DateTimeT, day: int = ..., month: int = ... +) -> Tuple[_DateTimeT, _DateTimeT]: ... def get_timedelta(qty: int, granularity: str) -> relativedelta: ... def start_of(value: _DateTimeT, granularity: str) -> _DateTimeT: ... def end_of(value: _DateTimeT, granularity: str) -> _DateTimeT: ... def add(value: _DateTimeT, *args, **kwargs) -> _DateTimeT: ... def subtract(value: _DateTimeT, *args, **kwargs) -> _DateTimeT: ... def json_default(obj) -> str: ... -def date_range(start: datetime.datetime, end: datetime.datetime, step: relativedelta = ...) -> Iterator[datetime.datetime]: ... +def date_range( + start: datetime.datetime, end: datetime.datetime, step: relativedelta = ... +) -> Iterator[datetime.datetime]: ... diff --git a/odoo-stubs/tools/float_utils.pyi b/odoo-stubs/tools/float_utils.pyi index c4cb251..4448339 100644 --- a/odoo-stubs/tools/float_utils.pyi +++ b/odoo-stubs/tools/float_utils.pyi @@ -1,9 +1,27 @@ def round(f: float) -> float: ... -def _float_check_precision(precision_digits: int | None = ..., precision_rounding: float | None = ...) -> float: ... -def float_round(value: float, precision_digits: int | None = ..., precision_rounding: float | None = ..., rounding_method: str = ...) -> float: ... -def float_is_zero(value: float, precision_digits: int | None = ..., precision_rounding: float | None = ...) -> bool: ... -def float_compare(value1: float, value2: float, precision_digits: int | None = ..., precision_rounding: float | None = ...) -> int: ... +def _float_check_precision( + precision_digits: int | None = ..., precision_rounding: float | None = ... +) -> float: ... +def float_round( + value: float, + precision_digits: int | None = ..., + precision_rounding: float | None = ..., + rounding_method: str = ..., +) -> float: ... +def float_is_zero( + value: float, + precision_digits: int | None = ..., + precision_rounding: float | None = ..., +) -> bool: ... +def float_compare( + value1: float, + value2: float, + precision_digits: int | None = ..., + precision_rounding: float | None = ..., +) -> int: ... def float_repr(value: float, precision_digits: int) -> str: ... + _float_repr = float_repr + def float_split_str(value: float, precision_digits: int) -> tuple[str, str]: ... def float_split(value: float, precision_digits: int) -> tuple[int, int]: ... diff --git a/odoo-stubs/tools/func.pyi b/odoo-stubs/tools/func.pyi index a6c95a2..7930d66 100644 --- a/odoo-stubs/tools/func.pyi +++ b/odoo-stubs/tools/func.pyi @@ -1,7 +1,7 @@ from json import JSONEncoder as JSONEncoder from typing import Callable, Generic, TypeVar -_T = TypeVar('_T') +_T = TypeVar("_T") class lazy_property(Generic[_T]): fget: Callable[..., _T] @@ -26,7 +26,7 @@ class _ClassProperty(property, Generic[_T]): def classproperty(func: Callable[..., _T]) -> _ClassProperty[_T]: ... class lazy: - __slots__ = ['_func', '_args', '_kwargs', '_cached_value'] + __slots__ = ["_func", "_args", "_kwargs", "_cached_value"] def __init__(self, func, *args, **kwargs) -> None: ... @property def _value(self): ... diff --git a/odoo-stubs/tools/graph.pyi b/odoo-stubs/tools/graph.pyi index a45974c..a293526 100644 --- a/odoo-stubs/tools/graph.pyi +++ b/odoo-stubs/tools/graph.pyi @@ -6,7 +6,9 @@ class graph: no_ancester: Any = ... transitions: Any = ... result: Any = ... - def __init__(self, nodes: Any, transitions: Any, no_ancester: Optional[Any] = ...) -> None: ... + def __init__( + self, nodes: Any, transitions: Any, no_ancester: Optional[Any] = ... + ) -> None: ... edge_wt: Any = ... def init_rank(self) -> None: ... reachable_nodes: Any = ... @@ -50,5 +52,12 @@ class graph: start: Any = ... def process(self, starting_node: Any) -> None: ... def __str__(self): ... - def scale(self, maxx: Any, maxy: Any, nwidth: int = ..., nheight: int = ..., margin: int = ...) -> None: ... + def scale( + self, + maxx: Any, + maxy: Any, + nwidth: int = ..., + nheight: int = ..., + margin: int = ..., + ) -> None: ... def result_get(self): ... diff --git a/odoo-stubs/tools/image.pyi b/odoo-stubs/tools/image.pyi index 5f99c14..172cd73 100644 --- a/odoo-stubs/tools/image.pyi +++ b/odoo-stubs/tools/image.pyi @@ -1,6 +1,7 @@ -from PIL import IcoImagePlugin as IcoImagePlugin, ImageOps as ImageOps from typing import Any, Iterable, Literal +from PIL import IcoImagePlugin as IcoImagePlugin +from PIL import ImageOps as ImageOps from PIL.Image import Image FILETYPE_BASE64_MAGICWORD: dict[bytes, str] @@ -14,13 +15,31 @@ class ImageProcess: image: Image | Literal[False] original_format: str def __init__(self, base64_source: bytes, verify_resolution: bool = ...) -> None: ... - def image_base64(self, quality: int = ..., output_format: str = ...) -> bytes | Literal[False]: ... + def image_base64( + self, quality: int = ..., output_format: str = ... + ) -> bytes | Literal[False]: ... def resize(self, max_width: int = ..., max_height: int = ...) -> ImageProcess: ... - def crop_resize(self, max_width: int, max_height: int, center_x: float = ..., center_y: float = ...) -> ImageProcess: ... + def crop_resize( + self, + max_width: int, + max_height: int, + center_x: float = ..., + center_y: float = ..., + ) -> ImageProcess: ... def colorize(self) -> ImageProcess: ... -def image_process(base64_source: bytes, size: tuple[int, int] = ..., verify_resolution: bool = ..., quality: int = ..., crop: str | None = ..., colorize: bool = ..., output_format: str = ...) -> bytes: ... -def average_dominant_color(colors: list[tuple[Any, Any]], mitigate: int = ..., max_margin: int = ...) -> tuple[Any, Any]: ... +def image_process( + base64_source: bytes, + size: tuple[int, int] = ..., + verify_resolution: bool = ..., + quality: int = ..., + crop: str | None = ..., + colorize: bool = ..., + output_format: str = ..., +) -> bytes: ... +def average_dominant_color( + colors: list[tuple[Any, Any]], mitigate: int = ..., max_margin: int = ... +) -> tuple[Any, Any]: ... def image_fix_orientation(image: Image) -> Image: ... def base64_to_image(base64_source: bytes) -> Image: ... def image_to_base64(image: Image, format: str | None, **params) -> bytes: ... diff --git a/odoo-stubs/tools/lru.pyi b/odoo-stubs/tools/lru.pyi index 0525b69..75a96e6 100644 --- a/odoo-stubs/tools/lru.pyi +++ b/odoo-stubs/tools/lru.pyi @@ -1,10 +1,10 @@ from threading import RLock -from typing import Any, Iterator, Generator +from typing import Any, Generator, Iterator -__all__ = ['LRU'] +__all__ = ["LRU"] class LRUNode: - __slots__ = ['prev', 'next', 'me'] + __slots__ = ["prev", "next", "me"] prev: Any me: Any next: Any diff --git a/odoo-stubs/tools/mail.pyi b/odoo-stubs/tools/mail.pyi index e3a3dd1..21a2d1f 100644 --- a/odoo-stubs/tools/mail.pyi +++ b/odoo-stubs/tools/mail.pyi @@ -21,12 +21,28 @@ class _Cleaner(clean.Cleaner): def strip_class(self, el: _Element) -> None: ... def parse_style(self, el: _Element) -> None: ... -def html_sanitize(src: str, silent: bool = ..., sanitize_tags: bool = ..., sanitize_attributes: bool = ..., sanitize_style: bool = ..., - strip_style: bool = ..., strip_classes: bool = ..., sanitize_form: bool = ...) -> Markup: ... +def html_sanitize( + src: str, + silent: bool = ..., + sanitize_tags: bool = ..., + sanitize_attributes: bool = ..., + sanitize_style: bool = ..., + strip_style: bool = ..., + strip_classes: bool = ..., + sanitize_form: bool = ..., +) -> Markup: ... def html_keep_url(text: str) -> str: ... -def html2plaintext(html: str, body_id: str | None = ..., encoding: str = ...) -> str: ... +def html2plaintext( + html: str, body_id: str | None = ..., encoding: str = ... +) -> str: ... def plaintext2html(text: str, container_tag: str = ...) -> Markup: ... -def append_content_to_html(html: str, content: str, plaintext: bool = ..., preserve: bool = ..., container_tag: str = ...) -> Markup: ... +def append_content_to_html( + html: str, + content: str, + plaintext: bool = ..., + preserve: bool = ..., + container_tag: str = ..., +) -> Markup: ... email_re: Pattern single_email_re: Pattern @@ -34,12 +50,29 @@ mail_header_msgid_re: Pattern email_addr_escapes_re: Pattern def generate_tracking_message_id(res_id: str) -> str: ... -def email_send(email_from: str, email_to: str, subject: str, body: str, email_cc: str | None = ..., email_bcc: str | None = ..., - reply_to: bool = ..., attachments: Any | None = ..., message_id: Any | None = ..., - references: Any | None = ..., openobject_id: bool = ..., debug: bool = ..., subtype: str = ..., - headers: Any | None = ..., smtp_server: Any | None = ..., smtp_port: Any | None = ..., - ssl: bool = ..., smtp_user: Any | None = ..., smtp_password: Any | None = ..., - cr: Any | None = ..., uid: Any | None = ...): ... +def email_send( + email_from: str, + email_to: str, + subject: str, + body: str, + email_cc: str | None = ..., + email_bcc: str | None = ..., + reply_to: bool = ..., + attachments: Any | None = ..., + message_id: Any | None = ..., + references: Any | None = ..., + openobject_id: bool = ..., + debug: bool = ..., + subtype: str = ..., + headers: Any | None = ..., + smtp_server: Any | None = ..., + smtp_port: Any | None = ..., + ssl: bool = ..., + smtp_user: Any | None = ..., + smtp_password: Any | None = ..., + cr: Any | None = ..., + uid: Any | None = ..., +): ... def email_split_tuples(text: str) -> list[str]: ... def email_split(text: str) -> list[str]: ... def email_split_and_format(text: str) -> list[str]: ... @@ -47,6 +80,8 @@ def email_normalize(text: str) -> str | Literal[False]: ... def email_escape_char(email_address: str) -> str: ... def email_domain_extract(email: str) -> str | Literal[False]: ... def decode_smtp_header(smtp_header, quoted: bool = ...) -> str: ... -def decode_message_header(message: Message, header: str, separator: str = ..., quoted: bool = ...) -> str: ... +def decode_message_header( + message: Message, header: str, separator: str = ..., quoted: bool = ... +) -> str: ... def formataddr(pair: tuple[str, str], charset: str = ...) -> str: ... def encapsulate_email(old_email: str, new_email: str) -> str: ... diff --git a/odoo-stubs/tools/mimetypes.pyi b/odoo-stubs/tools/mimetypes.pyi index 8ef9a09..db96f0c 100644 --- a/odoo-stubs/tools/mimetypes.pyi +++ b/odoo-stubs/tools/mimetypes.pyi @@ -2,7 +2,7 @@ import collections from re import Pattern from typing import Any, Literal -__all__ = ['guess_mimetype'] +__all__ = ["guess_mimetype"] _ooxml_dirs: dict[str, str] def _check_ooxml(data: bytes) -> str | Literal[False]: ... @@ -17,7 +17,7 @@ _ppt_pattern: Pattern def _check_olecf(data: bytes) -> str | Literal[False]: ... def _check_svg(data: bytes) -> str | None: ... -_Entry = collections.namedtuple('_Entry', ['mimetype', 'signatures', 'discriminants']) +_Entry = collections.namedtuple("_Entry", ["mimetype", "signatures", "discriminants"]) _mime_mappings: tuple[_Entry, ...] def guess_mimetype(bin_data: str, default: str | None = ...) -> str: ... diff --git a/odoo-stubs/tools/misc.pyi b/odoo-stubs/tools/misc.pyi index 8d3c9d4..34fa7c1 100644 --- a/odoo-stubs/tools/misc.pyi +++ b/odoo-stubs/tools/misc.pyi @@ -3,40 +3,73 @@ import pickle as pickle_ from collections.abc import Mapping, MutableMapping, MutableSet from logging import Filter, LogRecord from types import ModuleType -from typing import Any, Generic, IO, AnyStr, ItemsView, Iterable, Iterator, NoReturn, TypeVar, Callable +from typing import ( + IO, + Any, + AnyStr, + Callable, + Generic, + ItemsView, + Iterable, + Iterator, + NoReturn, + TypeVar, +) import xlsxwriter import xlwt from babel.core import Locale from xlwt import Worksheet +from ..api import Environment +from ..loglevels import exception_to_unicode as exception_to_unicode +from ..loglevels import get_encodings as get_encodings +from ..sql_db import Cursor from .cache import * from .parse_version import parse_version as parse_version -from ..api import Environment -from ..loglevels import exception_to_unicode as exception_to_unicode, get_encodings as get_encodings -from ..sql_db import Cursor -_T = TypeVar('_T') -_T1 = TypeVar('_T1') -_KT = TypeVar('_KT') -_VT = TypeVar('_VT') -_CallableT = TypeVar('_CallableT', bound=Callable) +_T = TypeVar("_T") +_T1 = TypeVar("_T1") +_KT = TypeVar("_KT") +_VT = TypeVar("_VT") +_CallableT = TypeVar("_CallableT", bound=Callable) SKIPPED_ELEMENT_TYPES: tuple NON_BREAKING_SPACE: str def find_in_path(name: str) -> str: ... -def _exec_pipe(prog, args, env: Mapping[str, str] | None = ...) -> tuple[IO[AnyStr] | None, IO[AnyStr] | None]: ... -def exec_command_pipe(name: str, *args) -> tuple[IO[AnyStr] | None, IO[AnyStr] | None]: ... +def _exec_pipe( + prog, args, env: Mapping[str, str] | None = ... +) -> tuple[IO[AnyStr] | None, IO[AnyStr] | None]: ... +def exec_command_pipe( + name: str, *args +) -> tuple[IO[AnyStr] | None, IO[AnyStr] | None]: ... def find_pg_tool(name: str) -> str: ... def exec_pg_environ() -> dict[str, str]: ... def exec_pg_command(name: str, *args) -> None: ... -def exec_pg_command_pipe(name: str, *args) -> tuple[IO[AnyStr] | None, IO[AnyStr] | None]: ... -def file_open(name: str, mode: str = ..., subdir: str = ..., pathinfo: bool = ..., filter_ext: Any | None = ...): ... -def _fileopen(path: str, mode: str, basedir: str, pathinfo, basename: str | None = ..., filter_ext: Any | None = ...): ... +def exec_pg_command_pipe( + name: str, *args +) -> tuple[IO[AnyStr] | None, IO[AnyStr] | None]: ... +def file_open( + name: str, + mode: str = ..., + subdir: str = ..., + pathinfo: bool = ..., + filter_ext: Any | None = ..., +): ... +def _fileopen( + path: str, + mode: str, + basedir: str, + pathinfo, + basename: str | None = ..., + filter_ext: Any | None = ..., +): ... def flatten(list) -> list: ... def reverse_enumerate(l): ... -def partition(pred: Callable[[_T], bool], elems: Iterable[_T]) -> tuple[list[_T], list[_T]]: ... +def partition( + pred: Callable[[_T], bool], elems: Iterable[_T] +) -> tuple[list[_T], list[_T]]: ... def topological_sort(elems: dict[_T, Any]) -> list[_T]: ... def merge_sequences(*iterables: Iterable[_T]) -> list[_T]: ... @@ -69,9 +102,15 @@ DATETIME_FORMATS_MAP: dict[str, str] POSIX_TO_LDML: dict[str, str] def posix_to_ldml(fmt: str, locale: Locale) -> str: ... -def split_every(n: int, iterable: Iterable[_T], piece_maker: Callable[[Iterable[_T]], _T1] = ...) -> Iterator[_T1]: ... -def get_and_group_by_field(cr: Cursor, uid: int, obj, ids, field: str, context: dict | None = ...) -> dict: ... -def get_and_group_by_company(cr: Cursor, uid: int, obj, ids, context: dict | None = ...) -> dict: ... +def split_every( + n: int, iterable: Iterable[_T], piece_maker: Callable[[Iterable[_T]], _T1] = ... +) -> Iterator[_T1]: ... +def get_and_group_by_field( + cr: Cursor, uid: int, obj, ids, field: str, context: dict | None = ... +) -> dict: ... +def get_and_group_by_company( + cr: Cursor, uid: int, obj, ids, context: dict | None = ... +) -> dict: ... def resolve_attr(obj, attr: str): ... def attrgetter(*items): ... def remove_accents(input_str: str) -> str: ... @@ -88,7 +127,12 @@ class mute_logger(Filter): def __init__(self, *loggers: str) -> None: ... def filter(self, record: LogRecord) -> int: ... def __enter__(self) -> None: ... - def __exit__(self, exc_type: Any | None = ..., exc_val: Any | None = ..., exc_tb: Any | None = ...) -> None: ... + def __exit__( + self, + exc_type: Any | None = ..., + exc_val: Any | None = ..., + exc_tb: Any | None = ..., + ) -> None: ... def __call__(self, func: _CallableT) -> _CallableT: ... _ph: Any @@ -105,14 +149,16 @@ class CountingStream(Generic[_T]): def stripped_sys_argv(*strip_args: str) -> list[str]: ... class ConstantMapping(Mapping[_KT, _VT]): - __slots__ = ['_value'] + __slots__ = ["_value"] _value: _VT def __init__(self, val: _VT) -> None: ... def __len__(self) -> int: ... def __iter__(self) -> Iterator: ... def __getitem__(self, item) -> _VT: ... -def dumpstacks(sig: Any | None = ..., frame: Any | None = ..., thread_idents: Any | None = ...) -> None: ... +def dumpstacks( + sig: Any | None = ..., frame: Any | None = ..., thread_idents: Any | None = ... +) -> None: ... def freehash(arg) -> int: ... def clean_context(context: dict[str, Any]) -> dict[str, Any]: ... @@ -127,7 +173,7 @@ class frozendict(dict): def __hash__(self) -> int: ... class Collector(Mapping[_KT, _VT]): - __slots__ = ['map'] + __slots__ = ["map"] _map: dict def __init__(self) -> None: ... def add(self, key: _KT, val: _T) -> None: ... @@ -136,7 +182,7 @@ class Collector(Mapping[_KT, _VT]): def __len__(self) -> int: ... class StackMap(MutableMapping): - __slots__ = ['_maps'] + __slots__ = ["_maps"] _maps: list[MutableMapping] def __init__(self, m: MutableMapping | None = ...) -> None: ... def __getitem__(self, key): ... @@ -149,7 +195,7 @@ class StackMap(MutableMapping): def popmap(self) -> MutableMapping: ... class OrderedSet(MutableSet): - __slots__ = ['_map'] + __slots__ = ["_map"] _map: dict def __init__(self, elems: Iterable = ...) -> None: ... def __contains__(self, elem) -> bool: ... @@ -162,17 +208,19 @@ class LastOrderedSet(OrderedSet): def add(self, elem) -> None: ... class IterableGenerator(Generic[_T]): - __slots__ = ['func', 'args'] + __slots__ = ["func", "args"] func: Callable args: tuple def __init__(self, func: Callable[..., _T], *args) -> None: ... def __iter__(self) -> _T: ... -def groupby(iterable: Iterable[_T], key: Callable[..., _T1] | None = ...) -> ItemsView[_T1, _T]: ... +def groupby( + iterable: Iterable[_T], key: Callable[..., _T1] | None = ... +) -> ItemsView[_T1, _T]: ... def unique(it: Iterable[_T]) -> Iterator[_T]: ... class Reverse: - __slots__ = ['val'] + __slots__ = ["val"] val: Any def __init__(self, val) -> None: ... def __eq__(self, other) -> bool: ... @@ -184,19 +232,46 @@ class Reverse: def ignore(*exc) -> None: ... def html_escape(text: str) -> str: ... -def get_lang(env: Environment, lang_code: str = ...) -> 'odoo.model.res_lang': ... +def get_lang(env: Environment, lang_code: str = ...) -> "odoo.model.res_lang": ... def babel_locale_parse(lang_code: str) -> Locale: ... -def formatLang(env: Environment, value, digits: int | None = ..., grouping: bool = ..., monetary: bool = ..., - dp: bool = ..., currency_obj: 'odoo.model.res_currency' = ...) -> str: ... -def format_date(env: Environment, value: datetime.date | datetime.datetime | str, lang_code: str = ..., - date_format: str = ...) -> str: ... +def formatLang( + env: Environment, + value, + digits: int | None = ..., + grouping: bool = ..., + monetary: bool = ..., + dp: bool = ..., + currency_obj: "odoo.model.res_currency" = ..., +) -> str: ... +def format_date( + env: Environment, + value: datetime.date | datetime.datetime | str, + lang_code: str = ..., + date_format: str = ..., +) -> str: ... def parse_date(env: Environment, value: str, lang_code: str = ...) -> datetime.date: ... -def format_datetime(env: Environment, value: str | datetime.datetime, tz: str = ..., - dt_format: str = ..., lang_code: str = ...) -> str: ... -def format_time(env: Environment, value, tz: str = ..., time_format: str = ..., lang_code: str = ...) -> str: ... -def _format_time_ago(env: Environment, time_delta: datetime.timedelta | int, lang_code: str = ..., - add_direction: bool = ...) -> str: ... -def format_amount(env: Environment, amount: float, currency: 'odoo.model.res_currency', lang_code: str = ...) -> str: ... +def format_datetime( + env: Environment, + value: str | datetime.datetime, + tz: str = ..., + dt_format: str = ..., + lang_code: str = ..., +) -> str: ... +def format_time( + env: Environment, value, tz: str = ..., time_format: str = ..., lang_code: str = ... +) -> str: ... +def _format_time_ago( + env: Environment, + time_delta: datetime.timedelta | int, + lang_code: str = ..., + add_direction: bool = ..., +) -> str: ... +def format_amount( + env: Environment, + amount: float, + currency: "odoo.model.res_currency", + lang_code: str = ..., +) -> str: ... def format_duration(value: float) -> str: ... def _consteq(str1: str, str2: str) -> bool: ... @@ -206,7 +281,9 @@ class Unpickler(pickle_.Unpickler): find_global: Any find_class: Any -def _pickle_load(stream: pickle_._ReadableFileobj, encoding: str = ..., errors: bool = ...): ... +def _pickle_load( + stream: pickle_._ReadableFileobj, encoding: str = ..., errors: bool = ... +): ... pickle: ModuleType diff --git a/odoo-stubs/tools/osutil.pyi b/odoo-stubs/tools/osutil.pyi index add8e05..1d49b7b 100644 --- a/odoo-stubs/tools/osutil.pyi +++ b/odoo-stubs/tools/osutil.pyi @@ -2,9 +2,16 @@ import ctypes from typing import Any, BinaryIO, Callable, Generator, Iterable, Iterator def listdir(dir: str, recursive: bool = ...) -> Iterable[str]: ... -def walksymlinks(top: str, topdown: bool = ..., onerror: Callable[[OSError], Any] | None = ...) -> Iterator[tuple[str, list[str], list[str]]]: ... +def walksymlinks( + top: str, topdown: bool = ..., onerror: Callable[[OSError], Any] | None = ... +) -> Iterator[tuple[str, list[str], list[str]]]: ... def tempdir() -> Generator[str, None, None]: ... -def zip_dir(path: str, stream: str | BinaryIO, include_dir: bool = ..., fnct_sort: Callable | None = ...) -> None: ... +def zip_dir( + path: str, + stream: str | BinaryIO, + include_dir: bool = ..., + fnct_sort: Callable | None = ..., +) -> None: ... getppid: Callable[[], int] is_running_as_nt_service: Callable[[], bool] diff --git a/odoo-stubs/tools/pdf.pyi b/odoo-stubs/tools/pdf.pyi index a1b8eff..b865435 100644 --- a/odoo-stubs/tools/pdf.pyi +++ b/odoo-stubs/tools/pdf.pyi @@ -1,7 +1,8 @@ from typing import Any, Iterable from PyPDF2 import PdfFileReader, PdfFileWriter -from PyPDF2.generic import ArrayObject as ArrayObject, IndirectObject +from PyPDF2.generic import ArrayObject as ArrayObject +from PyPDF2.generic import IndirectObject from PyPDF2.utils import b_ as b_ DEFAULT_PDF_DATETIME_FORMAT: str @@ -12,9 +13,12 @@ class OdooPdfFileWriter(PdfFileWriter): _reader: PdfFileReader | None _header: bytes _ID: Any - def __init__(self, *args, **kwargs): None + def __init__(self, *args, **kwargs): + None def addAttachment(self, fname: str, fdata, subtype: str = ...) -> None: ... def cloneReaderDocumentRoot(self, reader: PdfFileReader) -> None: ... def convert_to_pdfa(self) -> None: ... def add_file_metadata(self, metadata_content: bytes) -> None: ... - def _create_attachment_object(self, attachment: dict[str, Any]) -> IndirectObject: ... + def _create_attachment_object( + self, attachment: dict[str, Any] + ) -> IndirectObject: ... diff --git a/odoo-stubs/tools/profiler.pyi b/odoo-stubs/tools/profiler.pyi index 004b1ed..dd7ef2f 100644 --- a/odoo-stubs/tools/profiler.pyi +++ b/odoo-stubs/tools/profiler.pyi @@ -7,7 +7,20 @@ class _LogTracer: files: Any deep: Any first_frame: Any - def __init__(self, whitelist: Any | None = ..., blacklist: Any | None = ..., files: Any | None = ..., deep: bool = ...) -> None: ... + def __init__( + self, + whitelist: Any | None = ..., + blacklist: Any | None = ..., + files: Any | None = ..., + deep: bool = ..., + ) -> None: ... def tracer(self, frame, event, arg): ... -def profile(method: Any | None = ..., whitelist: Any | None = ..., blacklist=..., files: Any | None = ..., minimum_time: int = ..., minimum_queries: int = ...): ... +def profile( + method: Any | None = ..., + whitelist: Any | None = ..., + blacklist=..., + files: Any | None = ..., + minimum_time: int = ..., + minimum_queries: int = ..., +): ... diff --git a/odoo-stubs/tools/pycompat.pyi b/odoo-stubs/tools/pycompat.pyi index 66fb848..bdd9c43 100644 --- a/odoo-stubs/tools/pycompat.pyi +++ b/odoo-stubs/tools/pycompat.pyi @@ -1,6 +1,6 @@ from codecs import StreamReader, StreamWriter from csv import Dialect -from typing import BinaryIO, Iterable, Iterator, Protocol, Any +from typing import Any, BinaryIO, Iterable, Iterator, Protocol class _StreamReader(Protocol): def __call__(self, stream: BinaryIO, errors: str = ...) -> StreamReader: ... diff --git a/odoo-stubs/tools/safe_eval.pyi b/odoo-stubs/tools/safe_eval.pyi index 87a6d0e..a35acb1 100644 --- a/odoo-stubs/tools/safe_eval.pyi +++ b/odoo-stubs/tools/safe_eval.pyi @@ -1,7 +1,8 @@ -from opcode import HAVE_ARGUMENT as HAVE_ARGUMENT from types import CodeType from typing import Any, Iterator, Literal +from opcode import HAVE_ARGUMENT as HAVE_ARGUMENT + unsafe_eval = eval _ALLOWED_MODULES: list[str] _UNSAFE_ATTRIBUTES: list[str] @@ -12,14 +13,28 @@ _SAFE_OPCODES: set[int] def _get_opcodes(codeobj) -> Iterator[int]: ... def assert_no_dunder_name(code_obj: CodeType, expr: str) -> None: ... -def assert_valid_codeobj(allowed_codes: set[int], code_obj: CodeType, expr: str) -> None: ... +def assert_valid_codeobj( + allowed_codes: set[int], code_obj: CodeType, expr: str +) -> None: ... def test_expr(expr: str, allowed_codes: set[int], mode: str = ...): ... def const_eval(expr: str): ... def expr_eval(expr: str): ... -def _import(name: str, globals: dict | None = ..., locals: dict | None = ..., fromlist: list | None = ..., level: int = ...): ... +def _import( + name: str, + globals: dict | None = ..., + locals: dict | None = ..., + fromlist: list | None = ..., + level: int = ..., +): ... _BUILTINS: dict[str, Any] -def safe_eval(expr: str, globals_dict: dict | None = ..., locals_dict: dict | None = ..., mode: str = ..., - nocopy: bool = ..., locals_builtins: bool = ...): ... +def safe_eval( + expr: str, + globals_dict: dict | None = ..., + locals_dict: dict | None = ..., + mode: str = ..., + nocopy: bool = ..., + locals_builtins: bool = ..., +): ... def test_python_expr(expr: str, mode: str = ...) -> str | Literal[False]: ... diff --git a/odoo-stubs/tools/sql.pyi b/odoo-stubs/tools/sql.pyi index 80c25ef..fd27cf5 100644 --- a/odoo-stubs/tools/sql.pyi +++ b/odoo-stubs/tools/sql.pyi @@ -7,22 +7,56 @@ _CONFDELTYPES: dict[str, str] def existing_tables(cr: Cursor, tablenames: Iterable[str]) -> list[str]: ... def table_exists(cr: Cursor, tablename: str) -> bool: ... def table_kind(cr: Cursor, tablename: str) -> str | None: ... -def create_model_table(cr: Cursor, tablename: str, comment: str | None = ...) -> None: ... +def create_model_table( + cr: Cursor, tablename: str, comment: str | None = ... +) -> None: ... def table_columns(cr: Cursor, tablename: str) -> dict: ... def column_exists(cr: Cursor, tablename: str, columnname: str) -> int: ... -def create_column(cr: Cursor, tablename: str, columnname: str, columntype: str, comment: str | None = ...) -> None: ... -def rename_column(cr: Cursor, tablename: str, columnname1: str, columnname2: str) -> None: ... -def convert_column(cr: Cursor, tablename: str, columnname: str, columntype: str) -> None: ... +def create_column( + cr: Cursor, + tablename: str, + columnname: str, + columntype: str, + comment: str | None = ..., +) -> None: ... +def rename_column( + cr: Cursor, tablename: str, columnname1: str, columnname2: str +) -> None: ... +def convert_column( + cr: Cursor, tablename: str, columnname: str, columntype: str +) -> None: ... def set_not_null(cr: Cursor, tablename: str, columnname: str) -> None: ... def drop_not_null(cr: Cursor, tablename: str, columnname: str) -> None: ... -def constraint_definition(cr: Cursor, tablename: str, constraintname: str) -> str | None: ... -def add_constraint(cr: Cursor, tablename: str, constraintname: str, definition: str) -> None: ... +def constraint_definition( + cr: Cursor, tablename: str, constraintname: str +) -> str | None: ... +def add_constraint( + cr: Cursor, tablename: str, constraintname: str, definition: str +) -> None: ... def drop_constraint(cr: Cursor, tablename: str, constraintname: str) -> None: ... -def add_foreign_key(cr: Cursor, tablename1: str, columnname1: str, tablename2: str, columnname2: str, ondelete) -> Literal[True]: ... -def fix_foreign_key(cr: Cursor, tablename1: str, columnname1: str, tablename2: str, columnname2: str, ondelete) -> list[str]: ... +def add_foreign_key( + cr: Cursor, + tablename1: str, + columnname1: str, + tablename2: str, + columnname2: str, + ondelete, +) -> Literal[True]: ... +def fix_foreign_key( + cr: Cursor, + tablename1: str, + columnname1: str, + tablename2: str, + columnname2: str, + ondelete, +) -> list[str]: ... def index_exists(cr: Cursor, indexname: str) -> int: ... -def create_index(cr: Cursor, indexname: str, tablename: str, expressions: Iterable[str]) -> None: ... -def create_unique_index(cr: Cursor, indexname: str, tablename: str, expressions: Iterable[str]) -> None: ... +def create_index( + cr: Cursor, indexname: str, tablename: str, expressions: Iterable[str] +) -> None: ... +def create_unique_index( + cr: Cursor, indexname: str, tablename: str, expressions: Iterable[str] +) -> None: ... def drop_index(cr: Cursor, indexname: str, tablename: str) -> None: ... def drop_view_if_exists(cr: Cursor, viewname: str) -> None: ... def escape_psql(to_escape: str) -> str: ... diff --git a/odoo-stubs/tools/template_inheritance.pyi b/odoo-stubs/tools/template_inheritance.pyi index 7cbc797..caac91b 100644 --- a/odoo-stubs/tools/template_inheritance.pyi +++ b/odoo-stubs/tools/template_inheritance.pyi @@ -6,5 +6,9 @@ def add_text_before(node: _Element, text: str | None) -> None: ... def add_text_inside(node: _Element, text: str | None) -> None: ... def remove_element(node: _Element) -> None: ... def locate_node(arch: _Element, spec: _Element) -> _Element: ... -def apply_inheritance_specs(source: _Element, specs_tree: _Element, inherit_branding: bool = ..., - pre_locate: Callable[[_Element], Any] = ...) -> _Element: ... +def apply_inheritance_specs( + source: _Element, + specs_tree: _Element, + inherit_branding: bool = ..., + pre_locate: Callable[[_Element], Any] = ..., +) -> _Element: ... diff --git a/odoo-stubs/tools/test_reports.pyi b/odoo-stubs/tools/test_reports.pyi index f0970f6..b3fcbf8 100644 --- a/odoo-stubs/tools/test_reports.pyi +++ b/odoo-stubs/tools/test_reports.pyi @@ -1,10 +1,26 @@ from typing import Any, Literal -from . import config as config from ..sql_db import Cursor +from . import config as config -def try_report(cr: Cursor, uid: int, rname: str, ids, data: Any | None = ..., context: dict | None = ..., - our_module: Any | None = ..., report_type: Any | None = ...) -> bool: ... -def try_report_action(cr: Cursor, uid: int, action_id: int, active_model: str | None = ..., active_ids: list[int] | None = ..., - wiz_data: dict | None = ..., wiz_buttons: list[str] | None = ..., context: dict | None = ..., - our_module: str | None = ...) -> Literal[True]: ... +def try_report( + cr: Cursor, + uid: int, + rname: str, + ids, + data: Any | None = ..., + context: dict | None = ..., + our_module: Any | None = ..., + report_type: Any | None = ..., +) -> bool: ... +def try_report_action( + cr: Cursor, + uid: int, + action_id: int, + active_model: str | None = ..., + active_ids: list[int] | None = ..., + wiz_data: dict | None = ..., + wiz_buttons: list[str] | None = ..., + context: dict | None = ..., + our_module: str | None = ..., +) -> Literal[True]: ... diff --git a/odoo-stubs/tools/translate.pyi b/odoo-stubs/tools/translate.pyi index 4d3810d..0f2bb34 100644 --- a/odoo-stubs/tools/translate.pyi +++ b/odoo-stubs/tools/translate.pyi @@ -2,13 +2,13 @@ import csv from re import Match, Pattern from tarfile import TarFile from types import FrameType -from typing import Any, BinaryIO, Callable, Container, IO, Iterable, Iterator, NoReturn +from typing import IO, Any, BinaryIO, Callable, Container, Iterable, Iterator, NoReturn from lxml.etree import HTMLParser, _Element from polib import POFile -from .pycompat import _CsvWriter from ..sql_db import Connection, Cursor +from .pycompat import _CsvWriter WEB_TRANSLATION_COMMENT: str SKIPPED_ELEMENTS: tuple[str, ...] @@ -25,8 +25,12 @@ TRANSLATED_ATTRS: set[str] avoid_pattern: Pattern node_pattern: Pattern -def translate_xml_node(node: _Element, callback: Callable[[str], str | None], parse: Callable[[str], _Element], - serialize: Callable[[_Element], str]) -> _Element: ... +def translate_xml_node( + node: _Element, + callback: Callable[[str], str | None], + parse: Callable[[str], _Element], + serialize: Callable[[_Element], str], +) -> _Element: ... def parse_xml(text: str) -> _Element: ... def serialize_xml(node: _Element) -> str: ... @@ -36,19 +40,23 @@ def parse_html(text: str) -> _Element: ... def serialize_html(node: _Element) -> str: ... def xml_translate(callback: Callable[[str], str | None], value: str) -> str: ... def html_translate(callback: Callable[[str], str | None], value: str) -> str: ... -def translate(cr: Cursor, name: str, source_type: str, lang: str, source: str | None = ...) -> str: ... +def translate( + cr: Cursor, name: str, source_type: str, lang: str, source: str | None = ... +) -> str: ... def translate_sql_constraint(cr: Cursor, key: str, lang: str) -> str: ... class GettextAlias: def _get_db(self) -> Connection | None: ... - def _get_cr(self, frame: FrameType, allow_create: bool = ...) -> tuple[Cursor, bool]: ... + def _get_cr( + self, frame: FrameType, allow_create: bool = ... + ) -> tuple[Cursor, bool]: ... def _get_uid(self, frame: FrameType) -> int: ... def _get_lang(self, frame: FrameType) -> str: ... def __call__(self, source: str) -> str: ... def _get_translation(self, source: str) -> str: ... class _lt: - __slots__ = ['_source'] + __slots__ = ["_source"] _source: str def __init__(self, source: str) -> None: ... def __str__(self) -> str: ... @@ -66,7 +74,9 @@ re_escaped_replacements: dict[str, str] def _sub_replacement(match_obj: Match) -> str: ... def unquote(str: str) -> str: ... -def TranslationFileReader(source: IO, fileformat: str = ...) -> CSVFileReader | PoFileReader: ... +def TranslationFileReader( + source: IO, fileformat: str = ... +) -> CSVFileReader | PoFileReader: ... class CSVFileReader: source: csv.DictReader @@ -79,7 +89,12 @@ class PoFileReader: def __init__(self, source: str | IO): ... def __iter__(self) -> Iterator[dict[str, Any]]: ... -def TranslationFileWriter(target, fileformat: str = ..., lang: str | None = ..., modules: Iterable[str] | None = ...) -> CSVFileWriter | PoFileWriter | TarFileWriter: ... +def TranslationFileWriter( + target, + fileformat: str = ..., + lang: str | None = ..., + modules: Iterable[str] | None = ..., +) -> CSVFileWriter | PoFileWriter | TarFileWriter: ... class CSVFileWriter: writer: _CsvWriter @@ -92,7 +107,9 @@ class PoFileWriter: po: POFile def __init__(self, target: IO, modules: Iterable[str], lang: str) -> None: ... def write_rows(self, rows: Iterable) -> None: ... - def add_entry(self, modules, tnrs, source, trad, comments: Iterable[str] | None = ...) -> None: ... + def add_entry( + self, modules, tnrs, source, trad, comments: Iterable[str] | None = ... + ) -> None: ... class TarFileWriter: tar: TarFile @@ -100,15 +117,34 @@ class TarFileWriter: def __init__(self, target: IO, lang: str) -> None: ... def write_rows(self, rows: Iterable) -> None: ... -def trans_export(lang: str, modules: list[str], buffer, format: str, cr: Cursor) -> None: ... +def trans_export( + lang: str, modules: list[str], buffer, format: str, cr: Cursor +) -> None: ... def trans_parse_rml(de: Iterable) -> list[bytes]: ... def _push(callback: Callable[[str, int], Any], term: str, source_line: int) -> None: ... def in_modules(object_name: str, modules: Container[str]) -> bool: ... -def _extract_translatable_qweb_terms(element: _Element, callback: Callable[[str, int], Any]) -> None: ... +def _extract_translatable_qweb_terms( + element: _Element, callback: Callable[[str, int], Any] +) -> None: ... def babel_extract_qweb(fileobj: IO, keywords, comment_tags, options) -> list[tuple]: ... def trans_generate(lang: str, modules, cr: Cursor) -> list: ... -def trans_load(cr: Cursor, filename: str, lang: str, verbose: bool = ..., module_name: str | None = ..., context: dict | None = ...) -> None: ... -def trans_load_data(cr: Cursor, fileobj: IO, fileformat: str, lang_name: str | None = ..., verbose: bool = ..., module_name: str | None = ..., context: dict | None = ...) -> None: ... +def trans_load( + cr: Cursor, + filename: str, + lang: str, + verbose: bool = ..., + module_name: str | None = ..., + context: dict | None = ..., +) -> None: ... +def trans_load_data( + cr: Cursor, + fileobj: IO, + fileformat: str, + lang_name: str | None = ..., + verbose: bool = ..., + module_name: str | None = ..., + context: dict | None = ..., +) -> None: ... def get_locales(lang: str | None = ...) -> None: ... def resetlocale() -> str: ... def load_language(cr: Cursor, lang: str) -> None: ... diff --git a/odoo-stubs/tools/view_validation.pyi b/odoo-stubs/tools/view_validation.pyi index a14e7c7..a2463a0 100644 --- a/odoo-stubs/tools/view_validation.pyi +++ b/odoo-stubs/tools/view_validation.pyi @@ -8,7 +8,7 @@ from lxml.etree import RelaxNG, _Element from ..api import Environment from ..fields import Field -_CallableT = TypeVar('_CallableT', bound=Callable) +_CallableT = TypeVar("_CallableT", bound=Callable) _validators: defaultdict[str, list[Callable]] _relaxng_cache: dict[str, RelaxNG | None] @@ -18,7 +18,9 @@ READONLY: Pattern def _get_attrs_symbols() -> set[str]: ... def _view_is_editable(node: _Element) -> bool: ... def field_is_editable(field: Field, node: _Element) -> bool: ... -def get_attrs_field_names(env: Environment, arch: _Element, model, editable) -> list: ... +def get_attrs_field_names( + env: Environment, arch: _Element, model, editable +) -> list: ... def valid_view(arch: _Element, **kwargs) -> bool: ... def validate(*view_types: str) -> Callable[[_CallableT], _CallableT]: ... def relaxng(view_type: str) -> RelaxNG: ... diff --git a/odoo-stubs/tools/which.pyi b/odoo-stubs/tools/which.pyi index a873fe2..fbc0905 100644 --- a/odoo-stubs/tools/which.pyi +++ b/odoo-stubs/tools/which.pyi @@ -1,4 +1,5 @@ -from os import R_OK as R_OK, W_OK as W_OK +from os import R_OK as R_OK +from os import W_OK as W_OK from os.path import dirname as dirname from typing import Iterator @@ -8,5 +9,9 @@ windows: bool seen: set defpathext: list[str] -def which_files(file: str, mode: int = ..., path: str | None = ..., pathext: str | None = ...) -> Iterator[str]: ... -def which(file: str, mode: int = ..., path: str | None = ..., pathext: str | None = ...) -> str: ... +def which_files( + file: str, mode: int = ..., path: str | None = ..., pathext: str | None = ... +) -> Iterator[str]: ... +def which( + file: str, mode: int = ..., path: str | None = ..., pathext: str | None = ... +) -> str: ... diff --git a/odoo-stubs/tools/xml_utils.pyi b/odoo-stubs/tools/xml_utils.pyi index de765fb..647bb4f 100644 --- a/odoo-stubs/tools/xml_utils.pyi +++ b/odoo-stubs/tools/xml_utils.pyi @@ -1,6 +1,7 @@ +from typing import IO, Iterable + from lxml import etree from lxml.etree import _Element -from typing import IO, Iterable from ..api import Environment @@ -9,8 +10,21 @@ class odoo_resolver(etree.Resolver): def __init__(self, env: Environment) -> None: ... def resolve(self, url: str, id: str, context) -> str: ... -def _check_with_xsd(tree_or_str: str | _Element, stream: str | IO, env: Environment | None = ...) -> None: ... -def create_xml_node_chain(first_parent_node: _Element, nodes_list: Iterable[str], last_node_value: str | None = ...) -> list[_Element]: ... -def create_xml_node(parent_node: _Element, node_name: str, node_value: str | None = ...) -> _Element: ... -def cleanup_xml_node(xml_node_or_string: _Element | str, remove_blank_text: bool = ..., remove_blank_nodes: bool = ..., - indent_level: int = ..., indent_space: str = ...) -> _Element: ... +def _check_with_xsd( + tree_or_str: str | _Element, stream: str | IO, env: Environment | None = ... +) -> None: ... +def create_xml_node_chain( + first_parent_node: _Element, + nodes_list: Iterable[str], + last_node_value: str | None = ..., +) -> list[_Element]: ... +def create_xml_node( + parent_node: _Element, node_name: str, node_value: str | None = ... +) -> _Element: ... +def cleanup_xml_node( + xml_node_or_string: _Element | str, + remove_blank_text: bool = ..., + remove_blank_nodes: bool = ..., + indent_level: int = ..., + indent_space: str = ..., +) -> _Element: ...