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.

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM