-
- Downloads
[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))
Showing
- addons/account/account.py 2 additions, 2 deletionsaddons/account/account.py
- addons/account/account_invoice.py 2 additions, 2 deletionsaddons/account/account_invoice.py
- addons/report/models/report.py 8 additions, 8 deletionsaddons/report/models/report.py
- openerp/api.py 10 additions, 0 deletionsopenerp/api.py
Loading
Please register or sign in to comment