odoo10 api 装饰器

http://www.cnblogs.com/kfx2007/p/3894297.html

one:装饰record-style方法中的self为单一实例,被装饰的方法将会在每一条记录中循环调用,返回一个list结果集,如果和@returns一块用了,将返回连接的结果.

model:装饰record-style方法中的self为记录集

multi:同model,区别在于model中的相当于traditional-style中的model.method(cr,uid,args,context=context),而multi为model.method(cr,uid,ids,args,context=context)

constrains:返回一个指定了现实了字段限制的方法的字段依赖的装饰器,每个参数都必须是字段名

depends:返回一个指定了compute方法(或new style function fields)的依赖的装饰器,每个参数必须为以.隔开的字段名组成的字符串

onchagne:返回一个对给出的fields的onchange方法的装饰器,每个参数必须为字段名

returns(model,downgrade=None):返回一个返回参数model的实例的方法的装饰器,参数model:model名或self(当前model),参数downgrade:要从record-style转换成traditional-style的方法

原文地址:https://www.cnblogs.com/langxing/p/7498357.html