diff options
| author | Christophe Simonis <chs@odoo.com> | 2014-10-29 19:45:09 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2014-10-29 19:45:09 +0100 |
| commit | cf23a5dedaec67a3c34f6e4c3829f17fe8a054d0 (patch) | |
| tree | fc0bbda4aeb9d5b70e42c76386e484c22d26cd6f /openerp/tools/func.py | |
| parent | 8481fab1b1b3762f73ba5b472e12b702680144c2 (diff) | |
| parent | 92c7874eb8f4cf14c04d4d7b50853d56aef30436 (diff) | |
[MERGE] forward port of branch 8.0 up to 92c7874
Diffstat (limited to 'openerp/tools/func.py')
| -rw-r--r-- | openerp/tools/func.py | 10 |
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: |
