From 4fb1add8898c06dd27005cc416f2a31b3d2a7771 Mon Sep 17 00:00:00 2001 From: Trinh Anh Ngoc Date: Sun, 27 Aug 2023 16:17:05 +0700 Subject: [PATCH] Update stubs --- odoo-stubs/fields.pyi | 1 - odoo-stubs/http.pyi | 1 + odoo-stubs/models.pyi | 3 --- odoo-stubs/tests/form.pyi | 34 +++++++++++++++++++++++++--- odoo-stubs/tools/view_validation.pyi | 4 ++-- 5 files changed, 34 insertions(+), 9 deletions(-) diff --git a/odoo-stubs/fields.pyi b/odoo-stubs/fields.pyi index 95c95d8..7dca929 100644 --- a/odoo-stubs/fields.pyi +++ b/odoo-stubs/fields.pyi @@ -73,7 +73,6 @@ class Field(Generic[_FieldValueT], metaclass=MetaField): default: Any string: str | None help: str | None - invisible: bool readonly: bool required: bool states: dict[str, list[tuple]] | None diff --git a/odoo-stubs/http.pyi b/odoo-stubs/http.pyi index 93d3f66..4b1237c 100644 --- a/odoo-stubs/http.pyi +++ b/odoo-stubs/http.pyi @@ -30,6 +30,7 @@ DEFAULT_LANG: str def get_default_session() -> dict[str, Any]: ... +DEFAULT_MAX_CONTENT_LENGTH: int GEOIP_EMPTY_COUNTRY: geoip2.models.Country GEOIP_EMPTY_CITY: geoip2.models.City JSON_MIMETYPES: tuple[str, ...] diff --git a/odoo-stubs/models.pyi b/odoo-stubs/models.pyi index e548b73..c4a0a6c 100644 --- a/odoo-stubs/models.pyi +++ b/odoo-stubs/models.pyi @@ -280,9 +280,6 @@ class BaseModel(metaclass=MetaModel): orderby: str | None = ..., lazy: bool = ..., ) -> list[dict[str, Any]]: ... - 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) -> str: ... def _parent_store_compute(self): ... def _check_removed_columns(self, log: bool = ...) -> None: ... diff --git a/odoo-stubs/tests/form.pyi b/odoo-stubs/tests/form.pyi index 61cbb02..c8b52f6 100644 --- a/odoo-stubs/tests/form.pyi +++ b/odoo-stubs/tests/form.pyi @@ -1,11 +1,13 @@ import collections -from typing import Any, Generic, Iterator, TypeVar +from typing import Any, Generic, Iterable, Iterator, TypeVar from ..models import BaseModel _ModelT = TypeVar("_ModelT", bound=BaseModel) _FormT = TypeVar("_FormT", bound=Form) +MODIFIER_ALIASES: dict + class Form(Generic[_ModelT]): def __init__(self, record: _ModelT, view: Any | None = ...) -> None: ... def __getattr__(self, field_name: str): ... @@ -24,15 +26,40 @@ class O2MForm(Form): class UpdateDict(dict): def __init__(self, *args, **kwargs) -> None: ... + def __repr__(self) -> str: ... def changed_items(self) -> Iterator[tuple]: ... def update(self, *args, **kw) -> None: ... def clear(self) -> None: ... +class X2MValue(collections.abc.Sequence): + def __init__(self, iterable_of_vals: Iterable = ...) -> None: ... + def __repr__(self) -> str: ... + def __contains__(self, id_) -> bool: ... + def __getitem__(self, index): ... + def __iter__(self) -> Iterator: ... + def __len__(self) -> int: ... + def __eq__(self, other) -> bool: ... + def get_vals(self, id_): ... + def add(self, id_, vals) -> None: ... + def remove(self, id_) -> None: ... + def clear(self) -> None: ... + def create(self, vals) -> None: ... + def update(self, id_, changes, changed=...) -> None: ... + def to_list_of_vals(self) -> list: ... + +class O2MValue(X2MValue): + def __init__(self, iterable_of_vals: Iterable = ...) -> None: ... + def to_commands(self, convert_values=...) -> list: ... + +class M2MValue(X2MValue): + def to_commands(self) -> list: ... + class X2MProxy: def __init__(self, form: Form, field_name: str) -> None: ... + @property + def ids(self) -> list: ... class O2MProxy(X2MProxy): - def __init__(self, form: Form, field_name: str) -> None: ... def __len__(self) -> int: ... def new(self) -> O2MForm: ... def edit(self, index: int) -> O2MForm: ... @@ -48,7 +75,8 @@ class M2MProxy(X2MProxy, collections.abc.Sequence): def set(self, records: BaseModel) -> None: ... def clear(self) -> None: ... -def read_record(record: BaseModel, fields: dict) -> dict: ... +def convert_read_to_form(values: dict, fields: dict) -> dict: ... +def get_static_context(context_str: str) -> dict: ... class Dotter: def __init__(self, values) -> None: ... diff --git a/odoo-stubs/tools/view_validation.pyi b/odoo-stubs/tools/view_validation.pyi index 788d9f7..72538e1 100644 --- a/odoo-stubs/tools/view_validation.pyi +++ b/odoo-stubs/tools/view_validation.pyi @@ -8,9 +8,9 @@ _CallableT = TypeVar("_CallableT", bound=Callable) READONLY: Pattern -def get_variable_names(expr: str | _expr) -> set[str]: ... +def get_domain_value_names(domain) -> tuple[set[str], set[str]]: ... +def get_expression_field_names(expression) -> set[str]: ... def get_dict_asts(expr: str | _expr) -> dict: ... -def get_domain_identifiers(expr: str | _expr) -> tuple[set[str], set[str]]: ... def valid_view(arch: _Element, **kwargs) -> bool: ... def validate(*view_types: str) -> Callable[[_CallableT], _CallableT]: ... def relaxng(view_type: str) -> RelaxNG: ...