diff --git a/addons/account/tests/test_reconciliation.py b/addons/account/tests/test_reconciliation.py index aabf81e2bf4..725a207d3a2 100644 --- a/addons/account/tests/test_reconciliation.py +++ b/addons/account/tests/test_reconciliation.py @@ -1,3 +1,4 @@ +from odoo import api from odoo.addons.account.tests.account_test_classes import AccountingTestCase from odoo.tests import tagged import time diff --git a/addons/auth_signup/models/res_users.py b/addons/auth_signup/models/res_users.py index 7bf33663b5e..396b05bee0e 100644 --- a/addons/auth_signup/models/res_users.py +++ b/addons/auth_signup/models/res_users.py @@ -26,11 +26,11 @@ class ResUsers(models.Model): # In case we have no value if not value: - return TRUE_DOMAIN if negative else FALSE_DOMAIN + return expression.TRUE_DOMAIN if negative else expression.FALSE_DOMAIN if operator in ['in', 'not in']: if len(value) > 1: - return FALSE_DOMAIN if negative else TRUE_DOMAIN + return expression.FALSE_DOMAIN if negative else expression.TRUE_DOMAIN if value[0] == 'new': comp = '!=' if negative else '=' if value[0] == 'active': diff --git a/addons/base_sparse_field/models/models.py b/addons/base_sparse_field/models/models.py index ef5fc4e5dbf..77ea36a6bd8 100644 --- a/addons/base_sparse_field/models/models.py +++ b/addons/base_sparse_field/models/models.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- -from odoo import models, fields, api +from odoo import models, fields, api, _ +from odoo.exceptions import UserError class IrModelFields(models.Model): diff --git a/addons/hr_payroll/models/hr_salary_rule.py b/addons/hr_payroll/models/hr_salary_rule.py index 74052e7b290..30eab19115e 100644 --- a/addons/hr_payroll/models/hr_salary_rule.py +++ b/addons/hr_payroll/models/hr_salary_rule.py @@ -2,7 +2,7 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from odoo import api, fields, models, _ -from odoo.exceptions import UserError +from odoo.exceptions import UserError, ValidationError from odoo.tools.safe_eval import safe_eval from odoo.addons import decimal_precision as dp diff --git a/addons/hw_escpos/escpos/escpos.py b/addons/hw_escpos/escpos/escpos.py index 7159ac3b31e..372b9cb4ee3 100644 --- a/addons/hw_escpos/escpos/escpos.py +++ b/addons/hw_escpos/escpos/escpos.py @@ -523,7 +523,7 @@ class Escpos: if code: self._raw(code) else: - raise exception.BarcodeCodeError() + raise BarcodeCodeError() def receipt(self,xml): """ diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py index d5b70f08014..8d8fc13a407 100644 --- a/addons/mail/models/mail_channel.py +++ b/addons/mail/models/mail_channel.py @@ -4,7 +4,7 @@ import base64 from email.utils import formataddr import re -import uuid +from uuid import uuid4 from odoo import _, api, fields, models, modules, tools from odoo.exceptions import UserError @@ -56,7 +56,7 @@ class Channel(models.Model): ('channel', 'Channel')], 'Channel Type', default='channel') description = fields.Text('Description') - uuid = fields.Char('UUID', size=50, index=True, default=lambda self: '%s' % uuid.uuid4(), copy=False) + uuid = fields.Char('UUID', size=50, index=True, default=lambda self: str(uuid4()), copy=False) email_send = fields.Boolean('Send messages by email', default=False) # multi users channel channel_last_seen_partner_ids = fields.One2many('mail.channel.partner', 'channel_id', string='Last Seen') diff --git a/addons/point_of_sale/models/pos_config.py b/addons/point_of_sale/models/pos_config.py index 1b41565401d..ac1ffa6fec8 100644 --- a/addons/point_of_sale/models/pos_config.py +++ b/addons/point_of_sale/models/pos_config.py @@ -2,7 +2,7 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from datetime import datetime -import uuid +from uuid import uuid4 from odoo import api, fields, models, _ from odoo.exceptions import ValidationError @@ -114,7 +114,7 @@ class PosConfig(models.Model): proxy_ip = fields.Char(string='IP Address', size=45, help='The hostname or ip address of the hardware proxy, Will be autodetected if left empty.') active = fields.Boolean(default=True) - uuid = fields.Char(readonly=True, default=lambda self: str(uuid.uuid4()), + uuid = fields.Char(readonly=True, default=lambda self: str(uuid4()), help='A globally unique identifier for this pos configuration, used to prevent conflicts in client-generated data.') sequence_id = fields.Many2one('ir.sequence', string='Order IDs Sequence', readonly=True, help="This sequence is automatically created by Odoo but you can change it " diff --git a/addons/stock_account/models/account_invoice.py b/addons/stock_account/models/account_invoice.py index c6d3880140e..b2effb1f0da 100644 --- a/addons/stock_account/models/account_invoice.py +++ b/addons/stock_account/models/account_invoice.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, models +from odoo import api, models, fields import logging diff --git a/odoo/addons/test_pylint/tests/test_pylint.py b/odoo/addons/test_pylint/tests/test_pylint.py index 5681e013d38..2abff5781f2 100644 --- a/odoo/addons/test_pylint/tests/test_pylint.py +++ b/odoo/addons/test_pylint/tests/test_pylint.py @@ -23,9 +23,10 @@ _logger = logging.getLogger(__name__) class TestPyLint(TransactionCase): ENABLED_CODES = [ - 'E0601', # using variable before assignment - 'W0123', # eval used - 'W0101', # unreachable code + 'used-before-assignment', + 'undefined-variable', + 'eval-used', + 'unreachable', 'mixed-indentation', diff --git a/odoo/fields.py b/odoo/fields.py index 51e3456a383..db975603979 100644 --- a/odoo/fields.py +++ b/odoo/fields.py @@ -1653,7 +1653,8 @@ class Datetime(Field): # Received data is returned as buffer (in Python 2) or memoryview (in Python 3). _BINARY = memoryview if pycompat.PY2: - _BINARY = buffer #pylint: disable=buffer-builtin + #pylint: disable=buffer-builtin,undefined-variable + _BINARY = buffer class Binary(Field): type = 'binary' diff --git a/odoo/modules/migration.py b/odoo/modules/migration.py index e512d331caa..28a9c1c170d 100644 --- a/odoo/modules/migration.py +++ b/odoo/modules/migration.py @@ -21,7 +21,8 @@ if pycompat.PY2: fp, fname = tools.file_open(path, pathinfo=True) fp2 = None - if not isinstance(fp, file): # pylint: disable=file-builtin + # pylint: disable=file-builtin,undefined-variable + if not isinstance(fp, file): # imp.load_source need a real file object, so we create # one from the file-like object we get from file_open fp2 = os.tmpfile() diff --git a/odoo/tools/misc.py b/odoo/tools/misc.py index 09ad85d278b..42fcecd7498 100644 --- a/odoo/tools/misc.py +++ b/odoo/tools/misc.py @@ -1139,7 +1139,7 @@ def formatLang(env, value, digits=None, grouping=True, monetary=False, dp=False, digits = decimal_precision_obj.precision_get(dp) elif currency_obj: digits = currency_obj.decimal_places - elif (hasattr(value, '_field') and isinstance(value._field, (float_field, function_field)) and value._field.digits): + elif (hasattr(value, '_field') and getattr(value._field, 'digits', None)): digits = value._field.digits[1] if not digits and digits is not 0: digits = DEFAULT_DIGITS diff --git a/odoo/tools/pycompat.py b/odoo/tools/pycompat.py index 14195c4fa79..5f25e23e977 100644 --- a/odoo/tools/pycompat.py +++ b/odoo/tools/pycompat.py @@ -13,7 +13,7 @@ PY2 = sys.version_info[0] == 2 _Writer = collections.namedtuple('_Writer', 'writerow writerows') if PY2: - # pylint: disable=long-builtin,unichr-builtin,unicode-builtin + # pylint: disable=long-builtin,unichr-builtin,unicode-builtin,undefined-variable unichr = unichr text_type = unicode string_types = (str, unicode)