[FIX] models: during setup, reset properties memoized on model classes
This is necessary, because a model's class is kept when applying model extensions.
This commit is contained in:
@@ -140,3 +140,7 @@ class Parent2(models.AbstractModel):
|
||||
|
||||
def stuff(self):
|
||||
return super(Parent2, self).stuff() + 'P2'
|
||||
|
||||
@api.constrains('foo')
|
||||
def _check_foo(self):
|
||||
pass
|
||||
|
||||
@@ -116,3 +116,7 @@ class TestInherit(common.TransactionCase):
|
||||
# check method overriding
|
||||
self.assertEqual(parent.stuff(), 'P1P2')
|
||||
self.assertEqual(child.stuff(), 'P1P2C1')
|
||||
|
||||
# check properties memoized on model
|
||||
self.assertEqual(len(parent._constraint_methods), 1)
|
||||
self.assertEqual(len(child._constraint_methods), 1)
|
||||
|
||||
@@ -782,6 +782,10 @@ class BaseModel(object):
|
||||
for (key, _, msg) in cls._sql_constraints:
|
||||
cls.pool._sql_error[cls._table + '_' + key] = msg
|
||||
|
||||
# reset properties memoized on cls
|
||||
cls._constraint_methods = BaseModel._constraint_methods
|
||||
cls._onchange_methods = BaseModel._onchange_methods
|
||||
|
||||
@property
|
||||
def _constraint_methods(self):
|
||||
""" Return a list of methods implementing Python constraints. """
|
||||
|
||||
Reference in New Issue
Block a user