From c7950c5c1e8c25ce4d4a253cb0176cfb5c98e968 Mon Sep 17 00:00:00 2001 From: Trinh Anh Ngoc Date: Sun, 15 Nov 2020 19:04:07 +0700 Subject: [PATCH] Update stubs --- odoo-stubs/cli/__init__.pyi | 2 +- odoo-stubs/cli/cloc.pyi | 5 +++++ odoo-stubs/exceptions.pyi | 6 ++--- odoo-stubs/fields.pyi | 14 ++++++++---- odoo-stubs/http.pyi | 6 ++++- odoo-stubs/models.pyi | 9 ++++++-- odoo-stubs/modules/__init__.pyi | 2 +- odoo-stubs/modules/loading.pyi | 4 ++-- odoo-stubs/modules/module.pyi | 22 +------------------ odoo-stubs/modules/registry.pyi | 2 +- odoo-stubs/osv/expression.pyi | 3 --- odoo-stubs/osv/osv.pyi | 4 ++-- odoo-stubs/osv/query.pyi | 39 +++++++++++++++++++++++---------- odoo-stubs/service/security.pyi | 1 - odoo-stubs/service/server.pyi | 2 ++ odoo-stubs/sql_db.pyi | 2 +- odoo-stubs/tests/common.pyi | 19 +++++++++------- odoo-stubs/tests/loader.pyi | 9 ++++++++ odoo-stubs/tests/runner.pyi | 22 +++++++++++++++++++ odoo-stubs/tools/__init__.pyi | 2 +- odoo-stubs/tools/cloc.pyi | 24 ++++++++++++++++++++ odoo-stubs/tools/convert.pyi | 8 +++---- odoo-stubs/tools/json.pyi | 9 ++++++++ odoo-stubs/tools/mail.pyi | 2 ++ odoo-stubs/tools/misc.pyi | 15 +++++++------ odoo-stubs/tools/pdf.pyi | 6 ++++- odoo-stubs/tools/safe_eval.pyi | 12 ++++++++++ odoo-stubs/tools/sql.pyi | 1 + odoo-stubs/tools/translate.pyi | 7 ++++-- odoo-stubs/tools/xml_utils.pyi | 10 ++++++--- 30 files changed, 189 insertions(+), 80 deletions(-) create mode 100644 odoo-stubs/cli/cloc.pyi create mode 100644 odoo-stubs/tests/loader.pyi create mode 100644 odoo-stubs/tests/runner.pyi create mode 100644 odoo-stubs/tools/cloc.pyi create mode 100644 odoo-stubs/tools/json.pyi diff --git a/odoo-stubs/cli/__init__.pyi b/odoo-stubs/cli/__init__.pyi index 58db4fc..52b10d6 100644 --- a/odoo-stubs/cli/__init__.pyi +++ b/odoo-stubs/cli/__init__.pyi @@ -1,2 +1,2 @@ -from . import deploy as deploy, populate as populate, scaffold as scaffold, server as server, shell as shell, start as start +from . import cloc as cloc, deploy as deploy, populate as populate, scaffold as scaffold, server as server, shell as shell, start as start from .command import Command as Command, main as main diff --git a/odoo-stubs/cli/cloc.pyi b/odoo-stubs/cli/cloc.pyi new file mode 100644 index 0000000..8df60ae --- /dev/null +++ b/odoo-stubs/cli/cloc.pyi @@ -0,0 +1,5 @@ +from . import Command +from typing import Any + +class Cloc(Command): + def run(self, args: Any) -> None: ... diff --git a/odoo-stubs/exceptions.pyi b/odoo-stubs/exceptions.pyi index 6e3d24d..7225c80 100644 --- a/odoo-stubs/exceptions.pyi +++ b/odoo-stubs/exceptions.pyi @@ -1,4 +1,4 @@ -from typing import Any +from typing import Any, Optional _logger: Any @@ -8,7 +8,7 @@ class UserError(Exception): def name(self): ... class RedirectWarning(Exception): - def __init__(self, message: Any, action: Any, button_text: Any) -> None: ... + def __init__(self, message: Any, action: Any, button_text: Any, additional_context: Optional[Any] = ...) -> None: ... @property def name(self): ... @@ -26,7 +26,7 @@ class MissingError(UserError): ... class ValidationError(UserError): ... class except_orm(UserError): - def __init__(self, *args: Any, **kwargs: Any) -> None: ... + def __init__(self, name: Any, value: Optional[Any] = ...) -> None: ... class Warning(UserError): def __init__(self, *args: Any, **kwargs: Any) -> None: ... diff --git a/odoo-stubs/fields.pyi b/odoo-stubs/fields.pyi index 06dc275..7d1db40 100644 --- a/odoo-stubs/fields.pyi +++ b/odoo-stubs/fields.pyi @@ -5,6 +5,7 @@ from odoo.tools import date_utils DATE_LENGTH: Any DATETIME_LENGTH: Any +NO_ACCESS: str IR_MODELS: Any _logger: Any _schema: Any @@ -41,8 +42,8 @@ class Field(MetaField('DummyField', (object,), {})): index: bool = ... manual: bool = ... copy: bool = ... - depends: Any = ... - depends_context: Any = ... + _depends: Any = ... + _depends_context: Any = ... recursive: bool = ... compute: Any = ... compute_sudo: bool = ... @@ -74,6 +75,8 @@ class Field(MetaField('DummyField', (object,), {})): def _setup_attrs(self, model: Any, name: Any): ... def setup_full(self, model: Any) -> None: ... def _setup_regular_base(self, model: Any) -> None: ... + depends: Any = ... + depends_context: Any = ... def _setup_regular_full(self, model: Any) -> None: ... def _setup_related_full(self, model: Any) -> None: ... def traverse_related(self, record: Any): ... @@ -297,10 +300,11 @@ _BINARY = memoryview class Binary(Field): type: str = ... prefetch: bool = ... - depends_context: Any = ... + _depends_context: Any = ... attachment: bool = ... @property def column_type(self): ... + def _get_attrs(self, model: Any, name: Any): ... _description_attachment: Any = ... def convert_to_column(self, value: Any, record: Any, values: Optional[Any] = ..., validate: bool = ...): ... def convert_to_cache(self, value: Any, record: Any, validate: bool = ...): ... @@ -388,7 +392,7 @@ class Many2one(_Relational): def convert_to_display_name(self, value: Any, record: Any): ... def convert_to_onchange(self, value: Any, record: Any, names: Any): ... def write(self, records: Any, value: Any): ... - def _remove_inverses(self, records: Any, value: Any) -> None: ... + def _remove_inverses(self, records: Any, value: Any): ... def _update_inverses(self, records: Any, value: Any) -> None: ... class Many2oneReference(Integer): @@ -426,6 +430,7 @@ class One2many(_RelationalMulti): _description_relation_field: Any = ... def update_db(self, model: Any, columns: Any) -> None: ... def get_domain_list(self, records: Any): ... + # def __get__(self, records: Any, owner: Any): ... def read(self, records: Any): ... def write_real(self, records_commands_list: Any, create: bool = ...): ... def write_new(self, records_commands_list: Any): ... @@ -461,3 +466,4 @@ class Id(Field): def prefetch_many2one_ids(record: Any, field: Any): ... def prefetch_x2many_ids(record: Any, field: Any): ... +def apply_required(model: Any, field_name: Any) -> None: ... diff --git a/odoo-stubs/http.pyi b/odoo-stubs/http.pyi index fe7b1d9..7f38a88 100644 --- a/odoo-stubs/http.pyi +++ b/odoo-stubs/http.pyi @@ -56,6 +56,7 @@ class WebRequest: def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None: ... def set_handler(self, endpoint: Any, arguments: Any, auth: Any) -> None: ... def _handle_exception(self, exception: Any) -> None: ... + def _is_cors_preflight(self, endpoint: Any): ... def _call_function(self, *args: Any, **kwargs: Any): ... def registry_cr(self) -> None: ... @property @@ -85,6 +86,7 @@ class HttpRequest(WebRequest): params: Any = ... def __init__(self, *args: Any) -> None: ... def _handle_exception(self, exception: Any): ... + def _is_cors_preflight(self, endpoint: Any): ... def dispatch(self): ... def make_response(self, data: Any, headers: Optional[Any] = ..., cookies: Optional[Any] = ...): ... def render(self, template: Any, qcontext: Optional[Any] = ..., lazy: bool = ..., **kw: Any): ... @@ -120,11 +122,13 @@ class OpenERPSession(sessions.Session): def __init__(self, *args: Any, **kwargs: Any) -> None: ... def __getattr__(self, attr: Any): ... def __setattr__(self, k: Any, v: Any): ... + pre_uid: Any = ... db: Any = ... uid: Any = ... login: Any = ... + def authenticate(self, db: Any, login: Optional[Any] = ..., password: Optional[Any] = ...): ... session_token: Any = ... - def authenticate(self, db: Any, login: Optional[Any] = ..., password: Optional[Any] = ..., uid: Optional[Any] = ...): ... + def finalize(self) -> None: ... def check_security(self) -> None: ... def logout(self, keep_db: bool = ...) -> None: ... def _default_values(self) -> None: ... diff --git a/odoo-stubs/models.pyi b/odoo-stubs/models.pyi index 7826ec8..88aa89a 100644 --- a/odoo-stubs/models.pyi +++ b/odoo-stubs/models.pyi @@ -42,8 +42,10 @@ class NewId: def __eq__(self, other: Any) -> Any: ... def __hash__(self) -> Any: ... def __repr__(self): ... + def __str__(self): ... def origin_ids(ids: Any): ... +def expand_ids(id0: Any, ids: Any) -> None: ... IdType: Any PREFETCH_MAX: int @@ -63,6 +65,7 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})): _inherit: Any = ... _inherits: Any = ... _table: Any = ... + _table_query: Any = ... _sequence: Any = ... _sql_constraints: Any = ... _rec_name: Any = ... @@ -75,6 +78,7 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})): _needaction: bool = ... _translate: bool = ... _check_company_auto: bool = ... + _depends: Any = ... _transient_max_count: Any = ... _transient_max_hours: Any = ... env: Environment = ... @@ -158,7 +162,7 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})): def _read_group_raw(self, domain: Any, fields: Any, groupby: Any, offset: int = ..., limit: Optional[Any] = ..., orderby: bool = ..., lazy: bool = ...): ... def _read_group_resolve_many2one_fields(self, data: Any, fields: Any) -> None: ... def _inherits_join_add(self, current_model: Any, parent_model_name: Any, query: Any): ... - def _inherits_join_calc(self, alias: Any, fname: Any, query: Any, implicit: bool = ..., outer: bool = ...): ... + def _inherits_join_calc(self, alias: Any, fname: Any, query: Any): ... def _parent_store_compute(self): ... def _check_removed_columns(self, log: bool = ...) -> None: ... def _init_column(self, column_name: Any) -> None: ... @@ -222,11 +226,12 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})): _get_xml_ids: Any = ... @classmethod def is_transient(cls): ... - def search_read(self, domain: Optional[Any] = ..., fields: Optional[Any] = ..., offset: int = ..., limit: Optional[Any] = ..., order: Optional[Any] = ...): ... + def search_read(self, domain: Optional[Any] = ..., fields: Optional[Any] = ..., offset: int = ..., limit: Optional[Any] = ..., order: Optional[Any] = ..., **read_kwargs: Any): ... def toggle_active(self) -> None: ... def action_archive(self): ... def action_unarchive(self): ... def _register_hook(self) -> None: ... + def _unregister_hook(self) -> None: ... @classmethod def _patch_method(cls, name: Any, method: Any) -> None: ... @classmethod diff --git a/odoo-stubs/modules/__init__.pyi b/odoo-stubs/modules/__init__.pyi index 3e87be7..e47d9f6 100644 --- a/odoo-stubs/modules/__init__.pyi +++ b/odoo-stubs/modules/__init__.pyi @@ -1,3 +1,3 @@ from . import db as db, graph as graph, loading as loading, migration as migration, module as module, registry as registry from odoo.modules.loading import load_modules as load_modules, reset_modules_state as reset_modules_state -from odoo.modules.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 odoo.modules.module import adapt_version as adapt_version, check_resource_path as check_resource_path, 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 diff --git a/odoo-stubs/modules/loading.pyi b/odoo-stubs/modules/loading.pyi index 2b63c45..334f18e 100644 --- a/odoo-stubs/modules/loading.pyi +++ b/odoo-stubs/modules/loading.pyi @@ -3,8 +3,8 @@ from typing import Any, Optional _logger: Any _test_logger: Any -def load_data(cr: Any, idref: Any, mode: Any, kind: Any, package: Any, report: Any): ... -def load_demo(cr: Any, package: Any, idref: Any, mode: Any, report: Optional[Any] = ...): ... +def load_data(cr: Any, idref: Any, mode: Any, kind: Any, package: Any): ... +def load_demo(cr: Any, package: Any, idref: Any, mode: Any): ... def force_demo(cr: Any) -> None: ... def load_module_graph(cr: Any, graph: Any, status: Optional[Any] = ..., perform_checks: bool = ..., skip_modules: Optional[Any] = ..., report: Optional[Any] = ..., models_to_check: Optional[Any] = ...): ... def _check_module_names(cr: Any, module_names: Any) -> None: ... diff --git a/odoo-stubs/modules/module.pyi b/odoo-stubs/modules/module.pyi index fe4f53f..442614c 100644 --- a/odoo-stubs/modules/module.pyi +++ b/odoo-stubs/modules/module.pyi @@ -1,4 +1,3 @@ -import unittest from typing import Any, Optional MANIFEST_NAMES: Any @@ -21,6 +20,7 @@ def initialize_sys_path() -> None: ... def get_module_path(module: Any, downloaded: bool = ..., display_warning: bool = ...): ... def get_module_filetree(module: Any, dir: str = ...): ... def get_resource_path(module: Any, *args: Any): ... +def check_resource_path(mod_path: Any, *args: Any): ... get_module_resource = get_resource_path def get_resource_from_path(path: Any): ... @@ -32,25 +32,5 @@ def load_openerp_module(module_name: Any) -> None: ... def get_modules(): ... def get_modules_with_version(): ... def adapt_version(version: Any): ... -def get_test_modules(module: Any): ... -def _get_tests_modules(path: Any, module: Any): ... - -class OdooTestResult(unittest.result.TestResult): - def log(self, level: Any, msg: Any, *args: Any, test: Optional[Any] = ..., exc_info: Optional[Any] = ..., extra: Optional[Any] = ..., stack_info: bool = ..., caller_infos: Optional[Any] = ...) -> None: ... - def getDescription(self, test: Any): ... - def startTest(self, test: Any) -> None: ... - def addError(self, test: Any, err: Any) -> None: ... - def addFailure(self, test: Any, err: Any) -> None: ... - def addSubTest(self, test: Any, subtest: Any, err: Any) -> None: ... - def addSkip(self, test: Any, reason: Any) -> None: ... - def addUnexpectedSuccess(self, test: Any) -> None: ... - def logError(self, flavour: Any, test: Any, error: Any) -> None: ... - def getErrorCallerInfo(self, error: Any, test: Any): ... - -class OdooTestRunner: - def run(self, test: Any): ... current_test: Any - -def run_unit_tests(module_name: Any, position: str = ...): ... -def unwrap_suite(test: Any) -> None: ... diff --git a/odoo-stubs/modules/registry.pyi b/odoo-stubs/modules/registry.pyi index 7f40d15..73978d9 100644 --- a/odoo-stubs/modules/registry.pyi +++ b/odoo-stubs/modules/registry.pyi @@ -19,6 +19,7 @@ class Registry(Mapping): _fields_by_model: Any = ... _ordinary_tables: Any = ... _constraint_queue: Any = ... + __cache: Any = ... _init_modules: Any = ... updated_modules: Any = ... loaded_xmlids: Any = ... @@ -61,7 +62,6 @@ class Registry(Mapping): def add_foreign_key(self, table1: Any, column1: Any, table2: Any, column2: Any, ondelete: Any, model: Any, module: Any, force: bool = ...) -> None: ... def check_foreign_keys(self, cr: Any) -> None: ... def check_tables_exist(self, cr: Any) -> None: ... - def cache(self): ... def _clear_cache(self) -> None: ... def clear_caches(self) -> None: ... def is_an_ordinary_table(self, model: Any): ... diff --git a/odoo-stubs/osv/expression.pyi b/odoo-stubs/osv/expression.pyi index f665c61..7203e6f 100644 --- a/odoo-stubs/osv/expression.pyi +++ b/odoo-stubs/osv/expression.pyi @@ -24,14 +24,11 @@ def AND(domains: Any): ... def OR(domains: Any): ... def distribute_not(domain: Any): ... def _quote(to_quote: Any): ... -def generate_table_alias(src_table_alias: Any, joined_tables: Any = ...): ... -def get_alias_from_query(from_query: Any): ... def normalize_leaf(element: Any): ... def is_operator(element: Any): ... def is_leaf(element: Any, internal: bool = ...): ... def is_boolean(element: Any): ... def check_leaf(element: Any, internal: bool = ...) -> None: ... -def select_from_where(cr: Any, select_field: Any, from_table: Any, where_field: Any, where_ids: Any, where_operator: Any): ... def get_unaccent_wrapper(cr: Any): ... class expression: diff --git a/odoo-stubs/osv/osv.pyi b/odoo-stubs/osv/osv.pyi index 1d6a23e..6201c37 100644 --- a/odoo-stubs/osv/osv.pyi +++ b/odoo-stubs/osv/osv.pyi @@ -1,7 +1,7 @@ -from ..exceptions import UserError +from ..exceptions import except_orm from ..models import AbstractModel, Model, TransientModel -except_osv = UserError +except_osv = except_orm osv = Model osv_memory = TransientModel osv_abstract = AbstractModel diff --git a/odoo-stubs/osv/query.pyi b/odoo-stubs/osv/query.pyi index daeb0c9..1bed7cc 100644 --- a/odoo-stubs/osv/query.pyi +++ b/odoo-stubs/osv/query.pyi @@ -1,19 +1,36 @@ from typing import Any, Optional -def _quote(to_quote: Any): ... +IDENT_RE: Any + +def _from_table(table: Any, alias: Any): ... +def _generate_table_alias(src_table_alias: Any, link: Any): ... class Query: + _cr: Any = ... _tables: Any = ... - where_clause: Any = ... - where_clause_params: Any = ... - joins: Any = ... - extras: Any = ... - def __init__(self, tables: Optional[Any] = ..., where_clause: Optional[Any] = ..., where_clause_params: Optional[Any] = ..., joins: Optional[Any] = ..., extras: Optional[Any] = ...) -> None: ... - def add_table(self, table: Any) -> None: ... + _joins: Any = ... + _where_clauses: Any = ... + _where_params: Any = ... + order: Any = ... + limit: Any = ... + offset: Any = ... + def __init__(self, cr: Any, alias: Any, table: Optional[Any] = ...) -> None: ... + def add_table(self, alias: Any, table: Optional[Any] = ...) -> None: ... + def add_where(self, where_clause: Any, where_params: Any = ...) -> None: ... + def join(self, lhs_alias: Any, lhs_column: Any, rhs_table: Any, rhs_column: Any, link: Any, extra: Optional[Any] = ..., extra_params: Any = ...): ... + def left_join(self, lhs_alias: Any, lhs_column: Any, rhs_table: Any, rhs_column: Any, link: Any, extra: Optional[Any] = ..., extra_params: Any = ...): ... + def _join(self, kind: Any, lhs_alias: Any, lhs_column: Any, rhs_table: Any, rhs_column: Any, link: Any, extra: Optional[Any] = ..., extra_params: Any = ...): ... + def select(self, *args: Any): ... + def get_sql(self): ... + def _result(self): ... + def __str__(self): ... + def __bool__(self): ... + def __len__(self): ... + def __iter__(self) -> Any: ... @property def tables(self): ... - def _get_table_aliases(self): ... - def _get_alias_mapping(self): ... + @property + def where_clause(self): ... + @property + def where_clause_params(self): ... def add_join(self, connection: Any, implicit: bool = ..., outer: bool = ..., extra: Optional[Any] = ..., extra_params: Any = ...): ... - def get_sql(self): ... - def __str__(self): ... diff --git a/odoo-stubs/service/security.pyi b/odoo-stubs/service/security.pyi index 2465c63..48b9599 100644 --- a/odoo-stubs/service/security.pyi +++ b/odoo-stubs/service/security.pyi @@ -1,6 +1,5 @@ from typing import Any -def login(db: Any, login: Any, password: Any): ... def check(db: Any, uid: Any, passwd: Any): ... def compute_session_token(session: Any, env: Any): ... def check_session(session: Any, env: Any): ... diff --git a/odoo-stubs/service/server.pyi b/odoo-stubs/service/server.pyi index c8ce7b3..0d4e0eb 100644 --- a/odoo-stubs/service/server.pyi +++ b/odoo-stubs/service/server.pyi @@ -1,4 +1,6 @@ import werkzeug.serving +from ..tests import runner as runner +from itertools import chain as chain from typing import Any, Optional INOTIFY_LISTEN_EVENTS: Any diff --git a/odoo-stubs/sql_db.pyi b/odoo-stubs/sql_db.pyi index b77d17e..02db086 100644 --- a/odoo-stubs/sql_db.pyi +++ b/odoo-stubs/sql_db.pyi @@ -6,7 +6,7 @@ _logger: Any def unbuffer(symb: Any, cr: Any): ... def undecimalize(symb: Any, cr: Any): ... def adapt_string(adapted: Any): ... -def flush_env(cr: Any) -> None: ... +def flush_env(cr: Any, *, clear: bool = ...) -> None: ... def clear_env(cr: Any) -> None: ... re_from: Any diff --git a/odoo-stubs/tests/common.pyi b/odoo-stubs/tests/common.pyi index e6d1f88..2566519 100644 --- a/odoo-stubs/tests/common.pyi +++ b/odoo-stubs/tests/common.pyi @@ -55,7 +55,7 @@ class BaseCase(TreeCase): def with_user(self, login: Any) -> None: ... def _assertRaises(self, exception: Any, *, msg: Optional[Any] = ...) -> None: ... def assertRaises(self, exception: Any, func: Optional[Any] = ..., *args: Any, **kwargs: Any): ... - def assertQueries(self, expected: Any): ... + def assertQueries(self, expected: Any, flush: bool = ...): ... def assertQueryCount(self, default: int = ..., flush: bool = ..., **counters: Any): ... def assertRecordValues(self, records: Any, expected_values: Any): ... def shortDescription(self) -> None: ... @@ -123,7 +123,7 @@ class ChromeBrowser: def _format_stack(self, logrecord: Any) -> None: ... def console_formatter(self, args: Any): ... -class HttpCase(TransactionCase): +class HttpCaseCommon(BaseCase): registry_test_mode: bool = ... browser: Any = ... browser_size: str = ... @@ -132,20 +132,23 @@ class HttpCase(TransactionCase): xmlrpc_db: Any = ... xmlrpc_object: Any = ... def __init__(self, methodName: str = ...) -> None: ... + opener: Any = ... + def setUp(self) -> None: ... @classmethod def start_browser(cls) -> None: ... @classmethod def terminate_browser(cls) -> None: ... - session: Any = ... - session_id: Any = ... - opener: Any = ... - def setUp(self) -> None: ... def url_open(self, url: Any, data: Optional[Any] = ..., files: Optional[Any] = ..., timeout: int = ..., headers: Optional[Any] = ..., allow_redirects: bool = ...): ... def _wait_remaining_requests(self, timeout: int = ...): ... - def authenticate(self, user: Any, password: Any) -> None: ... + def logout(self, keep_db: bool = ...) -> None: ... + session: Any = ... + def authenticate(self, user: Any, password: Any): ... def browser_js(self, url_path: Any, code: Any, ready: str = ..., login: Optional[Any] = ..., timeout: int = ..., **kw: Any) -> None: ... def start_tour(self, url_path: Any, tour_name: Any, step_delay: Optional[Any] = ..., **kwargs: Any): ... +class HttpCase(HttpCaseCommon, TransactionCase): ... +class HttpSavepointCase(HttpCaseCommon, SavepointCase): ... + def users(*logins: Any): ... def warmup(func: Any, *args: Any, **kwargs: Any) -> None: ... def can_import(module: Any): ... @@ -157,7 +160,7 @@ class Form: def _o2m_set_edition_view(self, descr: Any, node: Any, level: Any) -> None: ... def __str__(self): ... def _process_fvg(self, model: Any, fvg: Any, level: int = ...) -> None: ... - def _init_from_defaults(self, model: Any): ... + def _init_from_defaults(self, model: Any) -> None: ... def _init_from_values(self, values: Any) -> None: ... def __getattr__(self, field: Any): ... def _get_modifier(self, field: Any, modifier: Any, default: bool = ..., modmap: Optional[Any] = ..., vals: Optional[Any] = ...): ... diff --git a/odoo-stubs/tests/loader.pyi b/odoo-stubs/tests/loader.pyi new file mode 100644 index 0000000..36ab2a3 --- /dev/null +++ b/odoo-stubs/tests/loader.pyi @@ -0,0 +1,9 @@ +from typing import Any + +_logger: Any + +def get_test_modules(module: Any): ... +def _get_tests_modules(path: Any, module: Any): ... +def make_suite(module_name: Any, position: str = ...): ... +def run_suite(suite: Any, module_name: Any): ... +def unwrap_suite(test: Any) -> None: ... diff --git a/odoo-stubs/tests/runner.pyi b/odoo-stubs/tests/runner.pyi new file mode 100644 index 0000000..2d55944 --- /dev/null +++ b/odoo-stubs/tests/runner.pyi @@ -0,0 +1,22 @@ +import unittest +from typing import Any, Optional + +_logger: Any + +class OdooTestResult(unittest.result.TestResult): + time_start: Any = ... + queries_start: Any = ... + def __init__(self) -> None: ... + def __str__(self): ... + shouldStop: Any = ... + def update(self, other: Any) -> None: ... + def log(self, level: Any, msg: Any, *args: Any, test: Optional[Any] = ..., exc_info: Optional[Any] = ..., extra: Optional[Any] = ..., stack_info: bool = ..., caller_infos: Optional[Any] = ...) -> None: ... + def getDescription(self, test: Any): ... + def startTest(self, test: Any) -> None: ... + def addError(self, test: Any, err: Any) -> None: ... + def addFailure(self, test: Any, err: Any) -> None: ... + def addSubTest(self, test: Any, subtest: Any, err: Any) -> None: ... + def addSkip(self, test: Any, reason: Any) -> None: ... + def addUnexpectedSuccess(self, test: Any) -> None: ... + def logError(self, flavour: Any, test: Any, error: Any) -> None: ... + def getErrorCallerInfo(self, error: Any, test: Any): ... diff --git a/odoo-stubs/tools/__init__.pyi b/odoo-stubs/tools/__init__.pyi index e18944e..2c9eb76 100644 --- a/odoo-stubs/tools/__init__.pyi +++ b/odoo-stubs/tools/__init__.pyi @@ -10,5 +10,5 @@ from .xml_utils import * from .date_utils import * from .convert import * from .template_inheritance import * -from . import appdirs as appdirs, osutil as osutil, pdf as pdf, pycompat as pycompat, win32 as win32 +from . import appdirs as appdirs, cloc as cloc, osutil as osutil, pdf as pdf, pycompat as pycompat, win32 as win32 from .config import config as config diff --git a/odoo-stubs/tools/cloc.pyi b/odoo-stubs/tools/cloc.pyi new file mode 100644 index 0000000..9cecae5 --- /dev/null +++ b/odoo-stubs/tools/cloc.pyi @@ -0,0 +1,24 @@ +from typing import Any, Optional + +VERSION: int +DEFAULT_EXCLUDE: Any +STANDARD_MODULES: Any +MAX_FILE_SIZE: Any + +class Cloc: + modules: Any = ... + code: Any = ... + total: Any = ... + errors: Any = ... + max_width: int = ... + def __init__(self) -> None: ... + def parse_xml(self, s: Any): ... + def parse_py(self, s: Any): ... + def parse_js(self, s: Any): ... + def book(self, module: Any, item: str = ..., count: Any = ...) -> None: ... + def count_path(self, path: Any, exclude: Optional[Any] = ...) -> None: ... + def count_modules(self, env: Any) -> None: ... + def count_customization(self, env: Any) -> None: ... + def count_env(self, env: Any) -> None: ... + def count_database(self, database: Any) -> None: ... + def report(self, verbose: bool = ..., width: Optional[Any] = ...): ... diff --git a/odoo-stubs/tools/convert.pyi b/odoo-stubs/tools/convert.pyi index 267a1c7..4ac0b46 100644 --- a/odoo-stubs/tools/convert.pyi +++ b/odoo-stubs/tools/convert.pyi @@ -2,6 +2,7 @@ from .misc import ustr as ustr from odoo import api as api from typing import Any, Optional +__all__: Any _logger: Any safe_eval: Any @@ -26,7 +27,7 @@ class xml_import: def _tag_report(self, rec: Any): ... def _tag_function(self, rec: Any) -> None: ... def _tag_act_window(self, rec: Any) -> None: ... - def _tag_menuitem(self, rec: Any) -> None: ... + def _tag_menuitem(self, rec: Any, parent: Optional[Any] = ...) -> None: ... def _tag_record(self, rec: Any): ... def _tag_template(self, el: Any): ... def id_get(self, id_str: Any, raise_if_not_found: bool = ...): ... @@ -40,15 +41,14 @@ class xml_import: module: Any = ... envs: Any = ... idref: Any = ... - assertion_report: Any = ... _noupdate: Any = ... xml_filename: Any = ... _tags: Any = ... - def __init__(self, cr: Any, module: Any, idref: Any, mode: Any, report: Optional[Any] = ..., noupdate: bool = ..., xml_filename: Optional[Any] = ...) -> None: ... + def __init__(self, cr: Any, module: Any, idref: Any, mode: Any, noupdate: bool = ..., xml_filename: Optional[Any] = ...) -> None: ... def parse(self, de: Any) -> None: ... DATA_ROOTS: Any = ... -def convert_file(cr: Any, module: Any, filename: Any, idref: Any, mode: str = ..., noupdate: bool = ..., kind: Optional[Any] = ..., report: Optional[Any] = ..., pathname: Optional[Any] = ...) -> None: ... +def convert_file(cr: Any, module: Any, filename: Any, idref: Any, mode: str = ..., noupdate: bool = ..., kind: Optional[Any] = ..., pathname: Optional[Any] = ...) -> None: ... def convert_sql_import(cr: Any, fp: Any) -> None: ... def convert_csv_import(cr: Any, module: Any, fname: Any, csvcontent: Any, idref: Optional[Any] = ..., mode: str = ..., noupdate: bool = ...) -> None: ... def convert_xml_import(cr: Any, module: Any, xmlfile: Any, idref: Optional[Any] = ..., mode: str = ..., noupdate: bool = ..., report: Optional[Any] = ...) -> None: ... diff --git a/odoo-stubs/tools/json.pyi b/odoo-stubs/tools/json.pyi new file mode 100644 index 0000000..b44e293 --- /dev/null +++ b/odoo-stubs/tools/json.pyi @@ -0,0 +1,9 @@ +from typing import Any + +JSON_SCRIPTSAFE_MAPPER: Any + +class JSON: + def loads(self, *args: Any, **kwargs: Any): ... + def dumps(self, *args: Any, **kwargs: Any): ... + +scriptsafe: Any diff --git a/odoo-stubs/tools/mail.pyi b/odoo-stubs/tools/mail.pyi index 99c00af..e14136c 100644 --- a/odoo-stubs/tools/mail.pyi +++ b/odoo-stubs/tools/mail.pyi @@ -21,6 +21,7 @@ def html_sanitize(src: Any, silent: bool = ..., sanitize_tags: bool = ..., sanit URL_REGEX: str TEXT_URL_REGEX: str +HTML_TAG_URL_REGEX: Any def validate_url(url: Any): ... def is_html_empty(html_content: Any): ... @@ -28,6 +29,7 @@ def html_keep_url(text: Any): ... def html2plaintext(html: Any, body_id: Optional[Any] = ..., encoding: str = ...): ... def plaintext2html(text: Any, container_tag: bool = ...): ... def append_content_to_html(html: Any, content: Any, plaintext: bool = ..., preserve: bool = ..., container_tag: bool = ...): ... +def prepend_html_content(html_body: Any, html_content: Any): ... email_re: Any single_email_re: Any diff --git a/odoo-stubs/tools/misc.pyi b/odoo-stubs/tools/misc.pyi index 7b79120..2c6349c 100644 --- a/odoo-stubs/tools/misc.pyi +++ b/odoo-stubs/tools/misc.pyi @@ -2,7 +2,6 @@ from .cache import * import pickle as pickle_ import xlsxwriter import xlwt -from collections import defaultdict from collections.abc import Mapping, MutableMapping, MutableSet from odoo.loglevels import exception_to_unicode as exception_to_unicode, get_encodings as get_encodings from typing import Any, Optional @@ -146,11 +145,13 @@ class OrderedSet(MutableSet): class LastOrderedSet(OrderedSet): def add(self, elem: Any) -> None: ... -class GroupCalls: - _func_args: Any = ... +class Callbacks: + __slots__: Any = ... + _funcs: Any = ... + data: Any = ... def __init__(self) -> None: ... - def __call__(self) -> None: ... - def add(self, func: Any, *types: Any): ... + def add(self, func: Any) -> None: ... + def run(self) -> None: ... def clear(self) -> None: ... class IterableGenerator: @@ -183,6 +184,8 @@ def parse_date(env: Any, value: Any, lang_code: bool = ...): ... def format_datetime(env: Any, value: Any, tz: bool = ..., dt_format: str = ..., lang_code: bool = ...): ... def format_time(env: Any, value: Any, tz: bool = ..., time_format: str = ..., lang_code: bool = ...): ... def _format_time_ago(env: Any, time_delta: Any, lang_code: bool = ..., add_direction: bool = ...): ... +def format_decimalized_number(number: Any, decimal: int = ...): ... +def format_decimalized_amount(amount: Any, currency: Optional[Any] = ...): ... def format_amount(env: Any, amount: Any, currency: Any, lang_code: bool = ...): ... def format_duration(value: Any): ... def _consteq(str1: Any, str2: Any): ... @@ -197,8 +200,6 @@ def _pickle_load(stream: Any, encoding: str = ..., errors: bool = ...): ... pickle: Any -def wrap_module(module: Any, attr_list: Any): ... - class DotDict(dict): def __getattr__(self, attrib: Any): ... diff --git a/odoo-stubs/tools/pdf.pyi b/odoo-stubs/tools/pdf.pyi index fcbc40c..7ab3e2a 100644 --- a/odoo-stubs/tools/pdf.pyi +++ b/odoo-stubs/tools/pdf.pyi @@ -1,10 +1,12 @@ from PyPDF2 import PdfFileReader, PdfFileWriter from PyPDF2.generic import ArrayObject as ArrayObject from PyPDF2.utils import b_ as b_ -from typing import Any +from typing import Any, Optional DEFAULT_PDF_DATETIME_FORMAT: str +def _unwrapping_get(self, key: Any, default: Optional[Any] = ...): ... + class BrandedFileWriter(PdfFileWriter): def __init__(self) -> None: ... PdfFileWriter = BrandedFileWriter @@ -12,6 +14,8 @@ PdfFileWriter = BrandedFileWriter def merge_pdf(pdf_data: Any): ... def rotate_pdf(pdf: Any): ... +old_init: Any + class OdooPdfFileReader(PdfFileReader): def getAttachments(self): ... diff --git a/odoo-stubs/tools/safe_eval.pyi b/odoo-stubs/tools/safe_eval.pyi index 69d4b34..5849f04 100644 --- a/odoo-stubs/tools/safe_eval.pyi +++ b/odoo-stubs/tools/safe_eval.pyi @@ -26,3 +26,15 @@ _BUILTINS: Any def safe_eval(expr: Any, globals_dict: Optional[Any] = ..., locals_dict: Optional[Any] = ..., mode: str = ..., nocopy: bool = ..., locals_builtins: bool = ...): ... def test_python_expr(expr: Any, mode: str = ...): ... +def check_values(d: Any): ... + +class wrap_module: + _repr: Any = ... + def __init__(self, module: Any, attributes: Any) -> None: ... + def __repr__(self): ... + +mods: Any +datetime: Any +json: Any +time: Any +pytz: Any diff --git a/odoo-stubs/tools/sql.pyi b/odoo-stubs/tools/sql.pyi index d34f5eb..9cee563 100644 --- a/odoo-stubs/tools/sql.pyi +++ b/odoo-stubs/tools/sql.pyi @@ -27,3 +27,4 @@ def drop_view_if_exists(cr: Any, viewname: Any) -> None: ... def escape_psql(to_escape: Any): ... def pg_varchar(size: int = ...): ... def reverse_order(order: Any): ... +def increment_field_skiplock(record: Any, field: Any): ... diff --git a/odoo-stubs/tools/translate.pyi b/odoo-stubs/tools/translate.pyi index 61e87d2..7c970fb 100644 --- a/odoo-stubs/tools/translate.pyi +++ b/odoo-stubs/tools/translate.pyi @@ -36,16 +36,19 @@ class GettextAlias: def _get_cr(self, frame: Any, allow_create: bool = ...): ... def _get_uid(self, frame: Any): ... def _get_lang(self, frame: Any): ... - def __call__(self, source: Any): ... + def __call__(self, source: Any, *args: Any, **kwargs: Any): ... def _get_translation(self, source: Any): ... class _lt: __slots__: Any = ... _source: Any = ... - def __init__(self, source: Any) -> None: ... + _args: Any = ... + def __init__(self, source: Any, *args: Any, **kwargs: Any) -> None: ... def __str__(self): ... def __eq__(self, other: Any) -> Any: ... def __lt__(self, other: Any) -> Any: ... + def __add__(self, other: Any): ... + def __radd__(self, other: Any): ... _: Any diff --git a/odoo-stubs/tools/xml_utils.pyi b/odoo-stubs/tools/xml_utils.pyi index 66b60da..08759a7 100644 --- a/odoo-stubs/tools/xml_utils.pyi +++ b/odoo-stubs/tools/xml_utils.pyi @@ -1,7 +1,11 @@ -from odoo.tools.misc import file_open as file_open +from lxml import etree from typing import Any, Optional -def check_with_xsd(tree_or_str: Any, stream: Any) -> None: ... -def _check_with_xsd(tree_or_str: Any, stream: Any) -> None: ... +class odoo_resolver(etree.Resolver): + env: Any = ... + def __init__(self, env: Any) -> None: ... + def resolve(self, url: Any, id: Any, context: Any): ... + +def _check_with_xsd(tree_or_str: Any, stream: Any, env: Optional[Any] = ...) -> None: ... def create_xml_node_chain(first_parent_node: Any, nodes_list: Any, last_node_value: Optional[Any] = ...): ... def create_xml_node(parent_node: Any, node_name: Any, node_value: Optional[Any] = ...): ...