diff --git a/openerp/addons/test_inherit/models.py b/openerp/addons/test_inherit/models.py index 0804e122a46..e82540df2b5 100644 --- a/openerp/addons/test_inherit/models.py +++ b/openerp/addons/test_inherit/models.py @@ -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 diff --git a/openerp/addons/test_inherit/tests/test_inherit.py b/openerp/addons/test_inherit/tests/test_inherit.py index c66539d470b..58bec9356ec 100644 --- a/openerp/addons/test_inherit/tests/test_inherit.py +++ b/openerp/addons/test_inherit/tests/test_inherit.py @@ -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) diff --git a/openerp/models.py b/openerp/models.py index 4da815ef71b..ee3d38c3a7e 100644 --- a/openerp/models.py +++ b/openerp/models.py @@ -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. """