Can I open a FORM VIEW via a button defined by using Server Actions?
Asked
Active
Viewed 511 times
1 Answers
2
Yes.
Both action types "Execute Python Code" and "Execute Several Actions" should work this way. The second one only when the last "child" action will be of type "Execute Python Code".
You have to set action
in the python code of an action, to open a form view.
In Odoo 12 there is already an example with app "account" installed. The ID of that action is account.action_invoice_tree2
and the code looks like:
action_values = env.ref('account.action_vendor_bill_template').read()[0]
new_help = model.complete_empty_list_help()
action_values.update({'help': action_values.get('help', '') + new_help})
action = action_values
So Odoo is expecting a dictionary like you probably already have used in your module's code. But instead of returning a dictionary, you have to set variable action
in server actions.
You can not only open form views, but also tree, kanban and so on.

CZoellner
- 13,553
- 3
- 25
- 38