Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
1804 Lượt xem

I have successfully been able to create, search, read, unlink and write records via jsonrpc however I now would like to call some server actions I have created in the database. Can anyone guide me to some documentation on how to do that?


Thank you.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

This is probably not relevant for OP anymore, but I was looking for the same thing, and didn't find any clear answers, so I'll post my findings in case someone else is looking for the same.

The method you want to call to run an action is "run", as you can see in the source code here :  ​
github dot com/odoo/odoo/blob/afc47d5a95e391ec667bb696e4afc5a2cf305d84/odoo/addons/base/models/ir_actions.py#L616

So just like the other rpc calls you've been able to do, you specify these things in args under params: your_db, your_user_id, your_api_key, model (ir.actions.server in this case), the method "run", and lastly the ID of the action you want to run.

So if you send a post request to your odoo-baseurl/jsonrpc with the below body in raw/json it should work just fine:

{
​"jsonrpc":"2.0",
​"method":"call",
​"params":{
​"service":"object",
​"method":"execute",
​"args":[
​"db",
​"uid",
​"api_key",
​"ir.actions.server",
​"run",
​id_of_action
​]
​}
}

Ảnh đại diện
Huỷ bỏ