diff options
| author | Raphael Collet <rco@openerp.com> | 2016-02-09 10:01:34 +0100 |
|---|---|---|
| committer | Raphael Collet <rco@openerp.com> | 2016-02-09 10:01:43 +0100 |
| commit | 5763c32a6dd558f65864c661a7c3d068f012df27 (patch) | |
| tree | a19a13388bea846f42ea810810e87a9c31f98503 /addons/mail/static/src/xml/thread.xml | |
| parent | d82e489add442f0bef52b58620c8d7988919872d (diff) | |
[FIX] addons: fix usage of decorators `api.v7`/`api.v8`
Specifically, when one API implementation calls the other one, it has to call
the method *from the same class*. Otherwise, overriding the method may result
in an infinite recursion. Consider:
class A(Model):
_name = 'stuff'
@api.v8
def foo(self):
return 42
@api.v7
def foo(self, cr, uid, context=None):
return self.browse(cr, uid, [], context).foo()
class B(Model):
_inherit = 'stuff'
def foo(self, cr, uid, context=None):
return super(B, self).foo(cr, uid, context=context) + 1
and now call: `env['stuff'].foo()`. This invokes `B.foo` (new-API), which
calls `B.foo` (old-API), which calls `A.foo` (old-API), which calls `B.foo`
(new-API) instead of `A.foo`!
This issue would not be present if old-API `A.foo` was defined as:
@api.v7
def foo(self, cr, uid, context=None):
return A.foo(self.browse(cr, uid, [], context))
Diffstat (limited to 'addons/mail/static/src/xml/thread.xml')
0 files changed, 0 insertions, 0 deletions
