[FIX] undefined variables (potential nameerror)

Backport 9ec0455abc and
6a601fe6dc as they fixed various
possible NameError but did so in later sub-releases.
This commit is contained in:
Xavier Morel
2018-07-19 13:37:10 +02:00
parent bc12428e17
commit 9f8eae34d1
11 changed files with 19 additions and 14 deletions
@@ -1,3 +1,4 @@
from odoo import api
from odoo.addons.account.tests.account_test_classes import AccountingTestCase
import time
import unittest
+2 -1
View File
@@ -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):
+2 -2
View File
@@ -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')
+2 -2
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import uuid
from uuid import uuid4
from odoo import api, fields, models, _
from odoo.exceptions import ValidationError
@@ -110,7 +110,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 "
@@ -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
+4 -3
View File
@@ -24,9 +24,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',
+2 -1
View File
@@ -1630,7 +1630,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'
+2 -1
View File
@@ -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()
+1 -1
View File
@@ -1069,7 +1069,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
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from lxml import etree
from odoo.tools.misc import file_open
from odoo.exceptions import UserError
def check_with_xsd(tree_or_str, stream):
raise UserError("Method 'check_with_xsd' deprecated ")