Update stubs

This commit is contained in:
Trinh Anh Ngoc
2023-04-10 17:41:14 +07:00
parent e51aedf2fb
commit b7de5e24cd
5 changed files with 108 additions and 86 deletions

View File

@@ -26,6 +26,7 @@ Default: object
def first(records: _ModelT) -> _ModelT: ... def first(records: _ModelT) -> _ModelT: ...
def resolve_mro(model: BaseModel, name: str, predicate: Callable[..., bool]): ... def resolve_mro(model: BaseModel, name: str, predicate: Callable[..., bool]): ...
def determine(needle: str | Callable, records: BaseModel, *args): ...
class MetaField(type): class MetaField(type):
by_type: dict by_type: dict
@@ -84,7 +85,6 @@ class Field(metaclass=MetaField):
related_attrs: list[tuple[str, str]] related_attrs: list[tuple[str, str]]
description_attrs: list[tuple[str, str]] description_attrs: list[tuple[str, str]]
def __init__(self, string: str = ..., **kwargs) -> None: ... def __init__(self, string: str = ..., **kwargs) -> None: ...
def new(self, **kwargs): ...
def __str__(self) -> str: ... def __str__(self) -> str: ...
def __repr__(self) -> str: ... def __repr__(self) -> str: ...
def __set_name__(self, owner: type[BaseModel], name: str) -> None: ... def __set_name__(self, owner: type[BaseModel], name: str) -> None: ...
@@ -231,7 +231,6 @@ class _String(Field):
def convert_to_cache(self, value, record: BaseModel, validate: bool = ...): ... def convert_to_cache(self, value, record: BaseModel, validate: bool = ...): ...
def convert_to_record(self, value, record: BaseModel): ... def convert_to_record(self, value, record: BaseModel): ...
def convert_to_write(self, value, record: BaseModel): ... def convert_to_write(self, value, record: BaseModel): ...
def get_trans_func(self, records: BaseModel) -> Callable: ...
def get_translation_dictionary(self, from_lang_value: str, to_lang_values: dict) -> dict: ... def get_translation_dictionary(self, from_lang_value: str, to_lang_values: dict) -> dict: ...
def _get_stored_translations(self, record: BaseModel) -> dict[str, str]: ... def _get_stored_translations(self, record: BaseModel) -> dict[str, str]: ...
def write(self, records: _ModelT, value) -> None: ... def write(self, records: _ModelT, value) -> None: ...

View File

@@ -1,2 +1,3 @@
from .common import * from .common import *
from . import common as common, test_parse_inline_template as test_parse_inline_template from . import common as common, test_parse_inline_template as test_parse_inline_template
from .form import Form as Form, M2MProxy as M2MProxy, O2MProxy as O2MProxy

View File

@@ -5,11 +5,10 @@ from concurrent.futures import Future
from itertools import count from itertools import count
from subprocess import Popen from subprocess import Popen
from threading import Thread from threading import Thread
from typing import Any, Callable, Generator, Generic, Iterator, Mapping, Match, TypeVar from typing import Any, Callable, Generator, Mapping, Match, TypeVar
from xmlrpc import client as xmlrpclib from xmlrpc import client as xmlrpclib
import requests import requests
from lxml.etree import _Element
from websocket import WebSocket from websocket import WebSocket
from . import case from . import case
@@ -25,8 +24,6 @@ from ..tools.profiler import Profiler
_T = TypeVar('_T') _T = TypeVar('_T')
_CallableT = TypeVar('_CallableT', bound=Callable) _CallableT = TypeVar('_CallableT', bound=Callable)
_ModelT = TypeVar('_ModelT', bound=BaseModel)
_FormT = TypeVar('_FormT', bound=Form)
InvalidStateError = Any InvalidStateError = Any
ADDONS_PATH: str ADDONS_PATH: str
@@ -229,83 +226,4 @@ def no_retry(arg: _T) -> _T: ...
def users(*logins: str) -> Callable[[_CallableT], _CallableT]: ... def users(*logins: str) -> Callable[[_CallableT], _CallableT]: ...
def warmup(func: _CallableT, *args, **kwargs) -> _CallableT: ... def warmup(func: _CallableT, *args, **kwargs) -> _CallableT: ...
def can_import(module: str) -> bool: ... def can_import(module: str) -> bool: ...
class Form(Generic[_ModelT]):
_env: Environment
_model: _ModelT
_view: dict
_values: dict
_changed: set
def __init__(self, recordp: _ModelT, view: _ModelT | str | None = ...) -> None: ...
def _get_view_fields(self, node: _Element, model: BaseModel) -> dict: ...
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 = ...): ...
_OPS: dict[str, Callable[..., bool]]
def _get_context(self, field: str): ...
def __setattr__(self, field: str, value) -> None: ...
def __enter__(self: _FormT) -> _FormT: ...
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 _perform_onchange(self, fields: list[str], context: dict | None = ...) -> dict: ...
def _onchange_values(self) -> dict: ...
def _onchange_values_(self, fields, record: dict) -> dict: ...
def _cleanup_onchange(self, descr: dict, value, current): ...
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 _onchange_values(self) -> dict: ...
def save(self) -> None: ...
def _values_to_save(self, all_fields: bool = ...) -> UpdateDict: ...
class UpdateDict(dict):
_changed: set
def __init__(self, *args, **kwargs) -> None: ...
def changed_items(self) -> Iterator[tuple[Any, Any]]: ...
def update(self, *args, **kw) -> None: ...
class X2MProxy:
_parent: Form
_field: str
def _assert_editable(self) -> None: ...
class O2MProxy(X2MProxy):
_records: list[dict]
def __init__(self, parent: Form, field: str) -> None: ...
def __len__(self) -> int: ...
@property
def _model(self) -> BaseModel: ...
@property
def _descr(self) -> dict: ...
def _command_index(self, for_record: int) -> int: ...
def new(self) -> O2MForm: ...
def edit(self, index: int): ...
def remove(self, index: int) -> None: ...
class M2MProxy(X2MProxy, collections.Sequence):
def __init__(self, parent: Form, field: str) -> None: ...
def __getitem__(self, it) -> BaseModel: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[BaseModel]: ...
def __contains__(self, record: BaseModel) -> bool: ...
def add(self, record: BaseModel) -> None: ...
def _get_ids(self) -> list[int]: ...
def remove(self, id: int | None = ..., index: int | None = ...) -> None: ...
def clear(self) -> None: ...
def record_to_values(fields: dict, record: BaseModel) -> dict: ...
def _cleanup_from_default(type_: str, value): ...
def _get_node(view, f, *arg): ...
def tagged(*tags: str) -> Callable[[_CallableT], _CallableT]: ... def tagged(*tags: str) -> Callable[[_CallableT], _CallableT]: ...

94
odoo-stubs/tests/form.pyi Normal file
View File

@@ -0,0 +1,94 @@
import collections
from typing import Any, Callable, Generic, Iterator, TypeVar
from lxml.etree import _Element
from ..api import Environment
from ..models import BaseModel
_ModelT = TypeVar('_ModelT', bound=BaseModel)
_FormT = TypeVar('_FormT', bound=Form)
class Form(Generic[_ModelT]):
_record: _ModelT
_env: Environment
_models_info: dict
_view: Any
_values: dict
_changed: set
def __init__(self, record: _ModelT, view: Any | None = ...) -> None: ...
def _process_view(self, tree: _Element, model: BaseModel, level: int = ...) -> dict: ...
def _get_one2many_edition_view(self, field_info: dict, node: _Element, level: int) -> dict: ...
def __str__(self) -> str: ...
def _init_from_defaults(self) -> None: ...
def __getattr__(self, field_name: str): ...
def __setattr__(self, field_name: str, value) -> None: ...
def _get_modifier(self, field_name: str, modifier: str, *, view: Any | None = ..., vals: dict | None = ...): ...
_OPS: dict[str, Callable]
def _get_context(self, field_name: str): ...
def _get_eval_context(self) -> dict: ...
def __enter__(self: _FormT) -> _FormT: ...
def __exit__(self, exc_type, exc_value, traceback) -> None: ...
def save(self) -> _ModelT: ...
@property
def record(self) -> _ModelT: ...
def _values_to_save(self, all_fields: bool = ...) -> dict: ...
def _values_to_save_(self, values: dict, fields: dict, view: dict, changed: set, all_fields: bool = ...,
modifiers_values: dict | None = ..., parent_link: str | None = ...) -> dict: ...
def _perform_onchange(self, field_name: str | None = ...) -> dict: ...
def _onchange_values(self) -> dict: ...
def _onchange_values_(self, fields: dict, values: dict) -> dict: ...
def _cleanup_onchange(self, field_info: dict, value, current): ...
class O2MForm(Form):
_proxy: O2MProxy
_index: int | None
def __init__(self, proxy: O2MProxy, index: int | None = ...) -> None: ...
def _get_modifier(self, field_name: str, modifier: str, *, view: Any | None = ..., vals: dict | None = ...): ...
def _get_eval_context(self) -> dict: ...
def _onchange_values(self) -> dict: ...
def save(self) -> None: ...
def _values_to_save(self, all_fields: bool = ...) -> dict: ...
class UpdateDict(dict):
_changed: set
def __init__(self, *args, **kwargs) -> None: ...
def changed_items(self) -> Iterator[tuple]: ...
def update(self, *args, **kw) -> None: ...
class X2MProxy:
_form: Form
_field: str
_field_info: dict
def __init__(self, form: Form, field_name: str) -> None: ...
def _assert_editable(self) -> None: ...
class O2MProxy(X2MProxy):
_records: list
def __init__(self, form: Form, field_name: str) -> None: ...
def __len__(self) -> int: ...
@property
def _model(self) -> BaseModel: ...
def new(self) -> O2MForm: ...
def edit(self, index: int) -> O2MForm: ...
def remove(self, index: int) -> None: ...
def _command_index(self, for_record: int) -> int: ...
class M2MProxy(X2MProxy, collections.abc.Sequence):
def __getitem__(self, index: int) -> BaseModel: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[BaseModel]: ...
def __contains__(self, record: BaseModel) -> bool: ...
def _get_ids(self) -> list: ...
def add(self, record: BaseModel) -> None: ...
def remove(self, id: int | None = ..., index: int | None = ...) -> None: ...
def clear(self) -> None: ...
def read_record(record: BaseModel, fields: dict) -> dict: ...
def _cleanup_from_default(type_: str, value): ...
class Dotter:
__slots__ = ['__values']
__values: Any
def __init__(self, values) -> None: ...
def __getattr__(self, key): ...

View File

@@ -1,3 +1,4 @@
import enum
from collections import defaultdict from collections import defaultdict
from typing import Iterable, Literal from typing import Iterable, Literal
@@ -8,7 +9,16 @@ _CONFDELTYPES: dict[str, str]
def existing_tables(cr: Cursor, tablenames: Iterable[str]) -> list[str]: ... def existing_tables(cr: Cursor, tablenames: Iterable[str]) -> list[str]: ...
def table_exists(cr: Cursor, tablename: str) -> bool: ... def table_exists(cr: Cursor, tablename: str) -> bool: ...
def table_kind(cr: Cursor, tablename: str) -> str | None: ...
class TableKind(enum.Enum):
Regular: str
Temporary: str
View: str
Materialized: str
Foreign: str
Other: None
def table_kind(cr: Cursor, tablename: str) -> TableKind | None: ...
SQL_ORDER_BY_TYPE: defaultdict SQL_ORDER_BY_TYPE: defaultdict