odoo开发笔记--ValueError Expected singleton

异常处理参考:https://stackoverflow.com/questions/31070640/valueerror-expected-singleton-odoo8

报错: ValueError Expected singleton: *******

原因是,odoo几个装饰器的使用需要注意,当你后台方法用了@api.multi,那么,该方法下的数据,需要for循环遍历一下,否则就会出现singleton 单例模式的错误!

@api.one
This decorator loops automatically on Records of RecordSet for you. Self is redefined as current record

@api.multi
Self will be the current RecordSet without iteration. It is the default behavior (multiple browsable objects). Methods which returns non premitive type data(list, dictionary, function) must be decorated with @api.multi

@api.model
This decorator will convert old API calls to decorated function to new API signature. It allows to be polite when migrating code. Self does not contain any record/recordset in methods which are decorated by this decorator.

 

posted @ 2019-06-26 15:39  hello-Jesson  阅读(2542)  评论(0编辑  收藏  举报