3 回答

TA貢獻(xiàn)1817條經(jīng)驗(yàn) 獲得超6個(gè)贊
您可以ir.actions.server在 Odoo 的技術(shù)部分創(chuàng)建或簡(jiǎn)化服務(wù)器操作。對(duì)于初學(xué)者來(lái)說(shuō),它有一些有趣的優(yōu)勢(shì):一些文檔。以下是來(lái)自 Odoo 10 的副本,并顯示了您在創(chuàng)建 python 代碼服務(wù)器操作時(shí)獲得的小文檔:
# Available variables:
# - time, datetime, dateutil, timezone: Python libraries
# - env: Odoo Environement
# - model: Model of the record on which the action is triggered
# - record: Record on which the action is triggered if there is one, otherwise None
# - records: Records on which the action is triggered if there is one, otherwise None
# - log : log(message), function to log debug information in logging table
# - Warning: Warning Exception to use with raise
# To return an action, assign: action = {...}
而且您來(lái)自菜單,因此 Odoo 不知道任何記錄。就用model.on_test()PROTOCOL已經(jīng)寫(xiě)好了。你還應(yīng)該裝飾你的方法,@api.model告訴 Odoo 這個(gè)方法的調(diào)用沒(méi)有涉及任何記錄。

TA貢獻(xiàn)1820條經(jīng)驗(yàn) 獲得超10個(gè)贊
試試這個(gè),而不是
<field name="code">self.on_test()</field>
改成
<field name="code">model.on_test()</field>
添加回答
舉報(bào)