|
Jeffery9@gmail.com 出品 @jeffery-陳帆 原理 ations OE定義了ir.actions.actions,并從中派生了眾多的子類
用來執(zhí)行相關(guān)的動作
Server action 其中有一個子類 ir.actions.server ,可以用來執(zhí)行服務(wù)器端的動作。 可以執(zhí)行的動作有; 'state': fields.selection([ ('client_action','Client Action'), ('dummy','Dummy'), ('loop','Iteration'), ('code','Python Code'), ('trigger','Trigger'), ('email','Email'), ('sms','SMS'), ('object_create','Create Object'), ('object_copy','Copy Object'), ('object_write','Write Object'), ('other','Multi Actions'), ], 'Action Type', required=True, size=32, help="Type of the Action that is to be executed"),
可以用來干各種事情
Automated Action Rules 模塊定義了 自動動作規(guī)則 -針對什么對象 -條件 -動作 ,即server_action定義的動作
何時觸發(fā)
使用場景 例如,
實際操作 建立server_actions. 菜單 Settings/ Technical/ Actions/ Server Actions
create一個新的action
object處選擇Task, 即project.task Action type選擇Email 其中可以選的action有很多,如下
定制郵件內(nèi)容
提示,如果不清楚object的屬性,可以點擊彈出窗口按鍵,彈出Task定義窗口
設(shè)置好相關(guān)的參數(shù)后,保存
至此,server_action設(shè)置好了。
設(shè)置automatic action rule以便可以觸發(fā)動作。 菜單 Settings/ Technical/ Automated Actions/ Automated Actions
create一個automatic action rule.
輸入規(guī)則名稱 選擇相應(yīng)的對象,在此選擇task ,即project.task
設(shè)置conditions 目的,用來過濾哪些對象可以執(zhí)行服務(wù)器動作
說明; Timer如果不設(shè)置,則當crete/update Object時觸發(fā)服務(wù)器動作;否則,按照定時器設(shè)定的時間觸發(fā),但是會按照trigger date設(shè)置的參數(shù)篩選相應(yīng)的對象實例。
設(shè)置actions
點擊Add按鈕,在彈出窗選擇已經(jīng)創(chuàng)建的server action或者建立新的server action.
提示; 可以添加多個動作,動作按sequence順序執(zhí)行
注意; Fields to change. 是指 change the fields of the object. Add Followers,是指 為此 instance of object指派 訂閱者(但有條件,具體看代碼 ;))
定時任務(wù) Automatic action rules是由 ir.cron定期執(zhí)行的,如
附加說明
注入到對象創(chuàng)建、修改方法的代碼
修改create方法
修改write方法
執(zhí)行動作時,修改 Fields to change 和Add Follower的相關(guān)代碼
總結(jié);
|
|
|
來自: gastonfeng > 《ODOO》