This commit is contained in:
Trinh Anh Ngoc
2019-12-09 22:09:04 +07:00
parent 9d990e0c3b
commit d97338d305
3 changed files with 35 additions and 27 deletions

View File

@@ -5,6 +5,8 @@
from collections import Mapping from collections import Mapping
from typing import Any, Optional from typing import Any, Optional
from werkzeug.local import Local
from .sql_db import Cursor from .sql_db import Cursor
class Params: class Params:
@@ -43,7 +45,8 @@ class Environment(Mapping):
cr: Cursor = ... cr: Cursor = ...
uid: int = ... uid: int = ...
context: dict = ... context: dict = ...
def envs(cls): ... @property
def envs(cls) -> Environments: ...
@classmethod @classmethod
def manage(cls) -> None: ... def manage(cls) -> None: ...
@classmethod @classmethod
@@ -63,9 +66,10 @@ class Environment(Mapping):
def __call__(self, cr: Optional[Any] = ..., user: Optional[Any] = ..., context: Optional[Any] = ...): ... def __call__(self, cr: Optional[Any] = ..., user: Optional[Any] = ..., context: Optional[Any] = ...): ...
def ref(self, xml_id: Any, raise_if_not_found: bool = ...): ... def ref(self, xml_id: Any, raise_if_not_found: bool = ...): ...
@property @property
def user(self): ... def user(self):
return self['res.users']
@property @property
def lang(self): ... def lang(self) -> str: ...
def do_in_draft(self): ... def do_in_draft(self): ...
@property @property
def in_draft(self): ... def in_draft(self): ...

View File

@@ -1,11 +1,11 @@
# Stubs for odoo.fields (Python 3) # Stubs for odoo.fields (Python 3)
# #
# NOTE: This dynamically typed stub was automatically generated by stubgen. # NOTE: This dynamically typed stub was automatically generated by stubgen.
import datetime
from .sql_db import LazyCursor
from .tools.mimetypes import guess_mimetype
from typing import Any, Optional from typing import Any, Optional
from .tools import date_utils
DATE_LENGTH: Any DATE_LENGTH: Any
DATETIME_LENGTH: Any DATETIME_LENGTH: Any
EMPTY_DICT: Any EMPTY_DICT: Any
@@ -60,7 +60,7 @@ class Field:
def read(self, records: Any): ... def read(self, records: Any): ...
def create(self, record_values: Any) -> None: ... def create(self, record_values: Any) -> None: ...
def write(self, records: Any, value: Any): ... 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 __set__(self, record: Any, value: Any) -> None: ...
def compute_value(self, records: Any) -> None: ... def compute_value(self, records: Any) -> None: ...
def determine_value(self, record: Any) -> None: ... def determine_value(self, record: Any) -> None: ...
@@ -137,17 +137,17 @@ class Date(Field):
type: str = ... type: str = ...
column_type: Any = ... column_type: Any = ...
column_cast_from: Any = ... column_cast_from: Any = ...
start_of: Any = ... start_of = date_utils.start_of
end_of: Any = ... end_of = date_utils.end_of
add: Any = ... add: date_utils.add
subtract: Any = ... subtract: date_utils.subtract
@staticmethod @staticmethod
def today(*args: Any): ... def today(*args: Any) -> datetime.date: ...
@staticmethod @staticmethod
def context_today(record: Any, timestamp: Optional[Any] = ...): ... def context_today(record: Any, timestamp: Optional[Any] = ...) -> datetime.date: ...
@staticmethod @staticmethod
def to_date(value: Any): ... def to_date(value: Any) -> datetime.date: ...
from_string: Any = ... from_string = to_date
@staticmethod @staticmethod
def to_string(value: Any): ... def to_string(value: Any): ...
def convert_to_cache(self, value: Any, record: Any, validate: bool = ...): ... def convert_to_cache(self, value: Any, record: Any, validate: bool = ...): ...
@@ -157,21 +157,21 @@ class Datetime(Field):
type: str = ... type: str = ...
column_type: Any = ... column_type: Any = ...
column_cast_from: Any = ... column_cast_from: Any = ...
start_of: Any = ... start_of = date_utils.start_of
end_of: Any = ... end_of = date_utils.end_of
add: Any = ... add = date_utils.add
subtract: Any = ... subtract: date_utils.subtract
@staticmethod @staticmethod
def now(*args: Any): ... def now(*args: Any) -> datetime.datetime: ...
@staticmethod @staticmethod
def today(*args: Any): ... def today(*args: Any) -> datetime.datetime: ...
@staticmethod @staticmethod
def context_timestamp(record: Any, timestamp: Any): ... def context_timestamp(record: Any, timestamp: Any) -> datetime.datetime: ...
@staticmethod @staticmethod
def to_datetime(value: Any): ... def to_datetime(value: Any) -> datetime.datetime: ...
from_string: Any = ... from_string = to_datetime
@staticmethod @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_cache(self, value: Any, record: Any, validate: bool = ...): ...
def convert_to_export(self, value: Any, record: Any): ... def convert_to_export(self, value: Any, record: Any): ...
def convert_to_display_name(self, value: Any, record: Any): ... def convert_to_display_name(self, value: Any, record: Any): ...

View File

@@ -6,6 +6,8 @@ from collections import MutableMapping
from typing import Any, Optional, List, Union, Sequence, Tuple, Dict, Generator from typing import Any, Optional, List, Union, Sequence, Tuple, Dict, Generator
from . import api, fields from . import api, fields
from .api import Environment
from .modules.registry import Registry
SearchDomain = List[Union[str, Sequence[str]]] SearchDomain = List[Union[str, Sequence[str]]]
RecordValue = Dict[str, Any] RecordValue = Dict[str, Any]
@@ -53,7 +55,9 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
_order: str _order: str
_context: Dict _context: Dict
_fields: Dict[str, fields.Field] _fields: Dict[str, fields.Field]
env: api.Environment id: int
env: Environment
pool: Registry
CONCURRENCY_CHECK_FIELD: str = ... CONCURRENCY_CHECK_FIELD: str = ...
def view_init(self, fields_list: Any) -> None: ... def view_init(self, fields_list: Any) -> None: ...
def compute_concurrency_field(self) -> 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_rights(self, operation: Any, raise_exception: bool = ...): ...
def check_access_rule(self, operation: Any) -> None: ... def check_access_rule(self, operation: Any) -> None: ...
def unlink(self): ... def unlink(self): ...
def write(self, vals: Any): ... def write(self, vals: RecordValue): ...
def create(self, vals_list: Union[RecordValue, List[RecordValue]]): ... def create(self, vals_list: Union[RecordValue, List[RecordValue]]): ...
def copy_data(self, default: Optional[Any] = ...): ... def copy_data(self, default: Optional[Any] = ...): ...
def copy_translations(old: Any, new: Any, excluded: Any = ...): ... def copy_translations(old: Any, new: Any, excluded: Any = ...): ...