diff --git a/odoo/addons/base/models/ir_model.py b/odoo/addons/base/models/ir_model.py index 5a739fbb9a0..676c1061ed5 100644 --- a/odoo/addons/base/models/ir_model.py +++ b/odoo/addons/base/models/ir_model.py @@ -1,18 +1,19 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. import datetime -import dateutil import itertools import logging import re import time from ast import literal_eval -from collections import defaultdict, Mapping +from collections import defaultdict +from collections.abc import Mapping from operator import itemgetter -from odoo import api, fields, models, SUPERUSER_ID, tools, _ +import dateutil + +from odoo import api, fields, models, tools, _ from odoo.exceptions import AccessError, UserError, ValidationError -from odoo.modules.registry import Registry from odoo.osv import expression from odoo.tools import pycompat, unique from odoo.tools.safe_eval import safe_eval diff --git a/odoo/addons/base/models/qweb.py b/odoo/addons/base/models/qweb.py index 30b1eb41e35..02eebb87fa3 100644 --- a/odoo/addons/base/models/qweb.py +++ b/odoo/addons/base/models/qweb.py @@ -5,7 +5,8 @@ import os.path import re import traceback -from collections import OrderedDict, Sized, Mapping +from collections import OrderedDict +from collections.abc import Sized, Mapping from functools import reduce from itertools import tee, count from textwrap import dedent @@ -18,13 +19,8 @@ from werkzeug.utils import escape as _escape from odoo.tools import pycompat, freehash -try: - import builtins - builtin_defaults = {name: getattr(builtins, name) for name in dir(builtins)} -except ImportError: - # pylint: disable=bad-python3-import - import __builtin__ - builtin_defaults = {name: getattr(__builtin__, name) for name in dir(__builtin__)} +import builtins +builtin_defaults = {name: getattr(builtins, name) for name in dir(builtins)} try: import astor diff --git a/odoo/addons/test_converter/tests/test_html.py b/odoo/addons/test_converter/tests/test_html.py index 5bae2a063d7..c18ad079339 100644 --- a/odoo/addons/test_converter/tests/test_html.py +++ b/odoo/addons/test_converter/tests/test_html.py @@ -3,6 +3,7 @@ import base64 import datetime import os +import re from odoo.tests import common from odoo.tools import html_escape as e @@ -37,7 +38,14 @@ class TestExport(common.TransactionCase): def converter(value, options=None, context=None): context = context or {} record = self.Model.with_context(context).new({name: value}) - return model.with_context(context).record_to_html(record, name, options or {}) + # normalise non-newline spaces: some versions of babel use regular + # spaces while others use non-break space when formatting timedeltas + # to the french locale + return re.sub( + r'[^\S\n\r]', # no \p{Zs} + ' ', + model.with_context(context).record_to_html(record, name, options or {}) + ) return converter diff --git a/odoo/api.py b/odoo/api.py index f4dbeb8b97f..42405b3d5f0 100644 --- a/odoo/api.py +++ b/odoo/api.py @@ -15,20 +15,19 @@ __all__ = [ ] import logging -from collections import defaultdict, Mapping +from collections import defaultdict +from collections.abc import Mapping from contextlib import contextmanager -from copy import deepcopy from inspect import signature from pprint import pformat from weakref import WeakSet -from decorator import decorate, decorator +from decorator import decorate from werkzeug.local import Local, release_local -import odoo +from .exceptions import CacheMiss +from .tools import frozendict, classproperty, lazy_property, StackMap from .tools.translate import _ -from odoo.tools import frozendict, classproperty, lazy_property, StackMap -from odoo.exceptions import CacheMiss _logger = logging.getLogger(__name__) diff --git a/odoo/models.py b/odoo/models.py index 998e150b962..c03bdcfb91f 100644 --- a/odoo/models.py +++ b/odoo/models.py @@ -34,7 +34,8 @@ import operator import pytz import re import uuid -from collections import defaultdict, MutableMapping, OrderedDict +from collections import defaultdict, OrderedDict +from collections.abc import MutableMapping from contextlib import closing from inspect import getmembers, currentframe from operator import attrgetter, itemgetter diff --git a/odoo/modules/registry.py b/odoo/modules/registry.py index b42ebc988d5..8d443138502 100644 --- a/odoo/modules/registry.py +++ b/odoo/modules/registry.py @@ -4,7 +4,8 @@ """ Models registries. """ -from collections import Mapping, defaultdict, deque +from collections import defaultdict, deque +from collections.abc import Mapping from contextlib import closing, contextmanager from functools import partial from operator import attrgetter diff --git a/odoo/netsvc.py b/odoo/netsvc.py index 8257dccdbcb..b731eb347bd 100644 --- a/odoo/netsvc.py +++ b/odoo/netsvc.py @@ -138,10 +138,14 @@ def init_logger(): # ignore deprecation warnings from invalid escape (there's a ton and it's # pretty likely a super low-value signal) warnings.filterwarnings('ignore', r'^invalid escape sequence \\.', category=DeprecationWarning) - # ignore warning from older setuptools version using imp - warnings.filterwarnings('ignore', category=DeprecationWarning, module='setuptools.depends') - # ignore warning from zeep using defusedxml.lxml - warnings.filterwarnings('ignore', category=DeprecationWarning, module='zeep.loader') + # ignore a bunch of warnings we can't really fix ourselves + for module in [ + 'setuptools.depends',# older setuptools version using imp + 'zeep.loader',# zeep using defusedxml.lxml + 'reportlab.lib.rl_safe_eval',# reportlab importing ABC from collections + 'xlrd/xlsx',# xlrd mischecks iter() on trees or something so calls deprecated getiterator() instead of iter() + ]: + warnings.filterwarnings('ignore', category=DeprecationWarning, module=module) from .tools.translate import resetlocale resetlocale() diff --git a/odoo/tools/misc.py b/odoo/tools/misc.py index b19e3b44923..ad599a5d8e5 100644 --- a/odoo/tools/misc.py +++ b/odoo/tools/misc.py @@ -5,54 +5,47 @@ """ Miscellaneous tools used by OpenERP. """ -from functools import wraps -import babel -import babel.dates -from contextlib import contextmanager +import cProfile +import collections import datetime -import math -import subprocess import io import os - -import collections -import passlib.utils import pickle as pickle_ -import pytz import re import socket +import subprocess import sys import threading import time +import traceback import types import unicodedata -import werkzeug.utils import zipfile -from collections import defaultdict, Iterable, Mapping, MutableMapping, MutableSet, OrderedDict +from collections import defaultdict, OrderedDict +from collections.abc import Iterable, Mapping, MutableMapping, MutableSet +from contextlib import contextmanager from difflib import HtmlDiff -from itertools import islice, groupby as itergroupby, repeat -from lxml import etree - -from .which import which -import traceback +from functools import wraps +from itertools import islice, groupby as itergroupby from operator import itemgetter -try: - # pylint: disable=bad-python3-import - import cProfile -except ImportError: - import profile as cProfile - - -from .config import config -from .cache import * -from .parse_version import parse_version -from . import pycompat +import babel +import babel.dates +import passlib.utils +import pytz +import werkzeug.utils +from lxml import etree import odoo +import odoo.addons # get_encodings, ustr and exception_to_unicode were originally from tools.misc. # There are moved to loglevels until we refactor tools. from odoo.loglevels import get_encodings, ustr, exception_to_unicode # noqa +from . import pycompat +from .cache import * +from .config import config +from .parse_version import parse_version +from .which import which _logger = logging.getLogger(__name__) @@ -158,7 +151,6 @@ def file_open(name, mode="r", subdir='addons', pathinfo=False): @return fileobject if pathinfo is False else (fileobject, filepath) """ - import odoo.modules as addons adps = odoo.addons.__path__ rtp = os.path.normcase(os.path.abspath(config['root_path'])) @@ -206,7 +198,6 @@ def file_open(name, mode="r", subdir='addons', pathinfo=False): def _fileopen(path, mode, basedir, pathinfo, basename=None): name = os.path.normpath(os.path.normcase(os.path.join(basedir, path))) - import odoo.modules as addons paths = odoo.addons.__path__ + [config['root_path']] for addons_path in paths: addons_path = os.path.normpath(os.path.normcase(addons_path)) + os.sep