diff --git a/base_attachment_object_storage/models/ir_attachment.py b/base_attachment_object_storage/models/ir_attachment.py index b7ea9f3f..396460f7 100644 --- a/base_attachment_object_storage/models/ir_attachment.py +++ b/base_attachment_object_storage/models/ir_attachment.py @@ -6,7 +6,7 @@ import os import time from contextlib import closing, contextmanager -from distutils.util import strtobool +from .strtobool import strtobool import psycopg2 diff --git a/base_attachment_object_storage/models/strtobool.py b/base_attachment_object_storage/models/strtobool.py new file mode 100644 index 00000000..12f4b828 --- /dev/null +++ b/base_attachment_object_storage/models/strtobool.py @@ -0,0 +1,21 @@ +_MAP = { + "y": True, + "yes": True, + "t": True, + "true": True, + "on": True, + "1": True, + "n": False, + "no": False, + "f": False, + "false": False, + "off": False, + "0": False, +} + + +def strtobool(value): + try: + return _MAP[str(value).lower()] + except KeyError as error: + raise ValueError('"{}" is not a valid bool value'.format(value)) from error diff --git a/cloud_platform/models/cloud_platform.py b/cloud_platform/models/cloud_platform.py index 4d8c4990..6bcce2fc 100644 --- a/cloud_platform/models/cloud_platform.py +++ b/cloud_platform/models/cloud_platform.py @@ -5,7 +5,7 @@ import os import re from collections import namedtuple -from distutils.util import strtobool +from .strtobool import strtobool from odoo import api, models from odoo.tools.config import config diff --git a/cloud_platform/models/strtobool.py b/cloud_platform/models/strtobool.py new file mode 100644 index 00000000..12f4b828 --- /dev/null +++ b/cloud_platform/models/strtobool.py @@ -0,0 +1,21 @@ +_MAP = { + "y": True, + "yes": True, + "t": True, + "true": True, + "on": True, + "1": True, + "n": False, + "no": False, + "f": False, + "false": False, + "off": False, + "0": False, +} + + +def strtobool(value): + try: + return _MAP[str(value).lower()] + except KeyError as error: + raise ValueError('"{}" is not a valid bool value'.format(value)) from error diff --git a/logging_json/json_log.py b/logging_json/json_log.py index 09d3cbce..a3ba3a4b 100644 --- a/logging_json/json_log.py +++ b/logging_json/json_log.py @@ -5,7 +5,7 @@ import os import threading import uuid -from distutils.util import strtobool +from .strtobool import strtobool from odoo import http diff --git a/logging_json/strtobool.py b/logging_json/strtobool.py new file mode 100644 index 00000000..12f4b828 --- /dev/null +++ b/logging_json/strtobool.py @@ -0,0 +1,21 @@ +_MAP = { + "y": True, + "yes": True, + "t": True, + "true": True, + "on": True, + "1": True, + "n": False, + "no": False, + "f": False, + "false": False, + "off": False, + "0": False, +} + + +def strtobool(value): + try: + return _MAP[str(value).lower()] + except KeyError as error: + raise ValueError('"{}" is not a valid bool value'.format(value)) from error