Ensure that objects in the Pool has __slots__
issue10719 review375361002
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Ensure with a test that objects in the Pool have __slots__
|
||||
* Use bigdecimal tag for XML-RPC
|
||||
* Use tuple in Dict value instead of list
|
||||
* Do not set record name on title of report get_email
|
||||
|
||||
@@ -32,6 +32,7 @@ FONT = os.path.join(os.path.dirname(__file__), 'fonts', 'karla.ttf')
|
||||
|
||||
|
||||
class ImageMixin:
|
||||
__slots__ = ()
|
||||
image = fields.Binary(
|
||||
"Image", file_id=file_id, store_prefix=store_prefix)
|
||||
image_id = fields.Char("Image ID", readonly=True)
|
||||
|
||||
@@ -8,7 +8,7 @@ from trytond.pool import Pool
|
||||
|
||||
def avatar_mixin(size=64, default=None):
|
||||
class AvatarMixin:
|
||||
|
||||
__slots__ = ()
|
||||
avatars = fields.One2Many(
|
||||
'ir.avatar', 'resource', lazy_gettext('ir.msg_avatars'), size=1)
|
||||
avatar = fields.Function(
|
||||
|
||||
@@ -6,19 +6,19 @@ from trytond.report import Report
|
||||
|
||||
|
||||
class TestMixin:
|
||||
pass
|
||||
__slots__ = ()
|
||||
|
||||
|
||||
class TestSecondMixin:
|
||||
pass
|
||||
__slots__ = ()
|
||||
|
||||
|
||||
class NotMixin:
|
||||
pass
|
||||
__slots__ = ()
|
||||
|
||||
|
||||
class ReportMixin:
|
||||
pass
|
||||
__slots__ = ()
|
||||
|
||||
|
||||
class DeactivableModelView(DeactivableMixin, ModelView):
|
||||
|
||||
@@ -744,6 +744,22 @@ class ModuleTestCase(unittest.TestCase):
|
||||
msg="ModelSingleton must appear before ModelSQL in the parent "
|
||||
"classes of '%s'." % mname)
|
||||
|
||||
@with_transaction()
|
||||
def test_pool_slots(self):
|
||||
"Test pool object has __slots__"
|
||||
for type_ in ['model', 'wizard', 'report']:
|
||||
for name, cls in Pool().iterobject(type_):
|
||||
if not isregisteredby(cls, self.module):
|
||||
continue
|
||||
if getattr(cls, '__no_slots__', None):
|
||||
continue
|
||||
for kls in cls.__mro__:
|
||||
if kls is object:
|
||||
continue
|
||||
self.assertTrue(hasattr(kls, '__slots__'),
|
||||
msg="The %s of %s '%s' has no __slots__"
|
||||
% (kls, type_, name))
|
||||
|
||||
@with_transaction()
|
||||
def test_buttons_registered(self):
|
||||
'Test all buttons are registered in ir.model.button'
|
||||
|
||||
Reference in New Issue
Block a user