[FIX] report: replace deprecated LooseVersion method
With this commit, the LooseVersion function comes from distutils which is deprecated [0] in Python 3.10 is replaced by parse_version. [0]: https://peps.python.org/pep-0632/ Part-of: odoo/odoo#91927
This commit is contained in:
@@ -6,7 +6,7 @@ from odoo import api, fields, models, tools, SUPERUSER_ID, _
|
||||
from odoo.exceptions import UserError, AccessError
|
||||
from odoo.tools.safe_eval import safe_eval, time
|
||||
from odoo.tools.misc import find_in_path
|
||||
from odoo.tools import config, is_html_empty
|
||||
from odoo.tools import config, is_html_empty, parse_version
|
||||
from odoo.http import request
|
||||
from odoo.osv.expression import NEGATIVE_TERM_OPERATORS, FALSE_DOMAIN
|
||||
|
||||
@@ -21,7 +21,6 @@ import json
|
||||
|
||||
from lxml import etree
|
||||
from contextlib import closing
|
||||
from distutils.version import LooseVersion
|
||||
from reportlab.graphics.barcode import createBarcodeDrawing
|
||||
from PyPDF2 import PdfFileWriter, PdfFileReader, utils
|
||||
from collections import OrderedDict
|
||||
@@ -69,12 +68,12 @@ else:
|
||||
match = re.search(b'([0-9.]+)', out)
|
||||
if match:
|
||||
version = match.group(0).decode('ascii')
|
||||
if LooseVersion(version) < LooseVersion('0.12.0'):
|
||||
if parse_version(version) < parse_version('0.12.0'):
|
||||
_logger.info('Upgrade Wkhtmltopdf to (at least) 0.12.0')
|
||||
wkhtmltopdf_state = 'upgrade'
|
||||
else:
|
||||
wkhtmltopdf_state = 'ok'
|
||||
if LooseVersion(version) >= LooseVersion('0.12.2'):
|
||||
if parse_version(version) >= parse_version('0.12.2'):
|
||||
wkhtmltopdf_dpi_zoom_ratio = True
|
||||
|
||||
if config['workers'] == 1:
|
||||
|
||||
@@ -7,7 +7,6 @@ try:
|
||||
except ImportError:
|
||||
pylint = None
|
||||
import subprocess
|
||||
from distutils.version import LooseVersion
|
||||
import os
|
||||
from os.path import join
|
||||
import sys
|
||||
@@ -53,10 +52,10 @@ class TestPyLint(TransactionCase):
|
||||
def test_pylint(self):
|
||||
if pylint is None:
|
||||
self._skip_test('please install pylint')
|
||||
required_pylint_version = LooseVersion('1.6.4')
|
||||
required_pylint_version = tools.parse_version('1.6.4')
|
||||
if sys.version_info >= (3, 6):
|
||||
required_pylint_version = LooseVersion('1.7.0')
|
||||
if LooseVersion(getattr(pylint, '__version__', '0.0.1')) < required_pylint_version:
|
||||
required_pylint_version = tools.parse_version('1.7.0')
|
||||
if tools.parse_version(getattr(pylint, '__version__', '0.0.1')) < required_pylint_version:
|
||||
self._skip_test('please upgrade pylint to >= %s' % required_pylint_version)
|
||||
|
||||
paths = [tools.config['root_path']]
|
||||
|
||||
Reference in New Issue
Block a user