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

Hello,


Can someone tell me how to do this?


Thank you so much for your help!

Ảnh đại diện
Huỷ bỏ
Tác giả

Thank you Ray!

In case I have to give a parameter, do I put it between the parenthesis of ".run()"?

Câu trả lời hay nhất
server_action = env['ir.actions.server'].search([('name','=','Second Server Action')])
if server_action:
server_action.run()
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Thanks for solution Ray, massive help.
To add further use case to this solution, we can specify context to run on specific records (using for loop for example) like this: (I prefer to use action id instead of name, since name can be changed easily)

server_action = env['ir.actions.server'].search([('id','=', your_server_action_id)])
if server_action:
​for record in records:
​server_action.with_context(active_id = record.id, active_model = 'your_model_name').run()




Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 3 23
1532
0
thg 7 21
4159
1
thg 1 21
4797
1
thg 1 19
4863
1
thg 1 18
4387