From d97338d305aef858cc61239e984ee03ee8fa3c6d Mon Sep 17 00:00:00 2001 From: Trinh Anh Ngoc Date: Mon, 9 Dec 2019 22:09:04 +0700 Subject: [PATCH] Update --- odoo-stubs/api.pyi | 10 +++++++--- odoo-stubs/fields.pyi | 44 +++++++++++++++++++++---------------------- odoo-stubs/models.pyi | 8 ++++++-- 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/odoo-stubs/api.pyi b/odoo-stubs/api.pyi index 2cda803..b31d2d5 100644 --- a/odoo-stubs/api.pyi +++ b/odoo-stubs/api.pyi @@ -5,6 +5,8 @@ from collections import Mapping from typing import Any, Optional +from werkzeug.local import Local + from .sql_db import Cursor class Params: @@ -43,7 +45,8 @@ class Environment(Mapping): cr: Cursor = ... uid: int = ... context: dict = ... - def envs(cls): ... + @property + def envs(cls) -> Environments: ... @classmethod def manage(cls) -> None: ... @classmethod @@ -63,9 +66,10 @@ class Environment(Mapping): def __call__(self, cr: Optional[Any] = ..., user: Optional[Any] = ..., context: Optional[Any] = ...): ... def ref(self, xml_id: Any, raise_if_not_found: bool = ...): ... @property - def user(self): ... + def user(self): + return self['res.users'] @property - def lang(self): ... + def lang(self) -> str: ... def do_in_draft(self): ... @property def in_draft(self): ... diff --git a/odoo-stubs/fields.pyi b/odoo-stubs/fields.pyi index 7f9f729..2636121 100644 --- a/odoo-stubs/fields.pyi +++ b/odoo-stubs/fields.pyi @@ -1,11 +1,11 @@ # Stubs for odoo.fields (Python 3) # # NOTE: This dynamically typed stub was automatically generated by stubgen. - -from .sql_db import LazyCursor -from .tools.mimetypes import guess_mimetype +import datetime from typing import Any, Optional +from .tools import date_utils + DATE_LENGTH: Any DATETIME_LENGTH: Any EMPTY_DICT: Any @@ -60,7 +60,7 @@ class Field: def read(self, records: Any): ... def create(self, record_values: Any) -> None: ... def write(self, records: Any, value: Any): ... - def __get__(self, record: Any, owner: Any): ... + # def __get__(self, record: Any, owner: Any): ... def __set__(self, record: Any, value: Any) -> None: ... def compute_value(self, records: Any) -> None: ... def determine_value(self, record: Any) -> None: ... @@ -137,17 +137,17 @@ class Date(Field): type: str = ... column_type: Any = ... column_cast_from: Any = ... - start_of: Any = ... - end_of: Any = ... - add: Any = ... - subtract: Any = ... + start_of = date_utils.start_of + end_of = date_utils.end_of + add: date_utils.add + subtract: date_utils.subtract @staticmethod - def today(*args: Any): ... + def today(*args: Any) -> datetime.date: ... @staticmethod - def context_today(record: Any, timestamp: Optional[Any] = ...): ... + def context_today(record: Any, timestamp: Optional[Any] = ...) -> datetime.date: ... @staticmethod - def to_date(value: Any): ... - from_string: Any = ... + def to_date(value: Any) -> datetime.date: ... + from_string = to_date @staticmethod def to_string(value: Any): ... def convert_to_cache(self, value: Any, record: Any, validate: bool = ...): ... @@ -157,21 +157,21 @@ class Datetime(Field): type: str = ... column_type: Any = ... column_cast_from: Any = ... - start_of: Any = ... - end_of: Any = ... - add: Any = ... - subtract: Any = ... + start_of = date_utils.start_of + end_of = date_utils.end_of + add = date_utils.add + subtract: date_utils.subtract @staticmethod - def now(*args: Any): ... + def now(*args: Any) -> datetime.datetime: ... @staticmethod - def today(*args: Any): ... + def today(*args: Any) -> datetime.datetime: ... @staticmethod - def context_timestamp(record: Any, timestamp: Any): ... + def context_timestamp(record: Any, timestamp: Any) -> datetime.datetime: ... @staticmethod - def to_datetime(value: Any): ... - from_string: Any = ... + def to_datetime(value: Any) -> datetime.datetime: ... + from_string = to_datetime @staticmethod - def to_string(value: Any): ... + def to_string(value: Any) -> str: ... def convert_to_cache(self, value: Any, record: Any, validate: bool = ...): ... def convert_to_export(self, value: Any, record: Any): ... def convert_to_display_name(self, value: Any, record: Any): ... diff --git a/odoo-stubs/models.pyi b/odoo-stubs/models.pyi index 224a319..cb28ff2 100644 --- a/odoo-stubs/models.pyi +++ b/odoo-stubs/models.pyi @@ -6,6 +6,8 @@ from collections import MutableMapping from typing import Any, Optional, List, Union, Sequence, Tuple, Dict, Generator from . import api, fields +from .api import Environment +from .modules.registry import Registry SearchDomain = List[Union[str, Sequence[str]]] RecordValue = Dict[str, Any] @@ -53,7 +55,9 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})): _order: str _context: Dict _fields: Dict[str, fields.Field] - env: api.Environment + id: int + env: Environment + pool: Registry CONCURRENCY_CHECK_FIELD: str = ... def view_init(self, fields_list: Any) -> None: ... def compute_concurrency_field(self) -> None: ... @@ -88,7 +92,7 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})): def check_access_rights(self, operation: Any, raise_exception: bool = ...): ... def check_access_rule(self, operation: Any) -> None: ... def unlink(self): ... - def write(self, vals: Any): ... + def write(self, vals: RecordValue): ... def create(self, vals_list: Union[RecordValue, List[RecordValue]]): ... def copy_data(self, default: Optional[Any] = ...): ... def copy_translations(old: Any, new: Any, excluded: Any = ...): ...