summaryrefslogtreecommitdiff
path: root/openerp/tools/func.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2014-10-29 19:45:09 +0100
committerChristophe Simonis <chs@odoo.com>2014-10-29 19:45:09 +0100
commitcf23a5dedaec67a3c34f6e4c3829f17fe8a054d0 (patch)
treefc0bbda4aeb9d5b70e42c76386e484c22d26cd6f /openerp/tools/func.py
parent8481fab1b1b3762f73ba5b472e12b702680144c2 (diff)
parent92c7874eb8f4cf14c04d4d7b50853d56aef30436 (diff)
[MERGE] forward port of branch 8.0 up to 92c7874
Diffstat (limited to 'openerp/tools/func.py')
-rw-r--r--openerp/tools/func.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/openerp/tools/func.py b/openerp/tools/func.py
index 03b4f76669a..f04bacd3ee8 100644
--- a/openerp/tools/func.py
+++ b/openerp/tools/func.py
@@ -20,7 +20,7 @@
#
##############################################################################
-__all__ = ['synchronized', 'lazy_property', 'conditional']
+__all__ = ['synchronized', 'lazy_property', 'classproperty', 'conditional']
from functools import wraps
from inspect import getsourcefile
@@ -116,4 +116,12 @@ def compose(a, b):
return a(b(*args, **kwargs))
return wrapper
+
+class _ClassProperty(property):
+ def __get__(self, cls, owner):
+ return self.fget.__get__(None, owner)()
+
+def classproperty(func):
+ return _ClassProperty(classmethod(func))
+
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: