Skip to Content
Menu
This question has been flagged
1 Reply
24924 Views

I am using Odoo v.11 EE.

I'm following the "create a module" tutorial on the official docs (https://www.odoo.com/documentation/11.0/howtos/backend.html), so I made a 'course' module and a 'session' module etc, with no great issues.

If i go to the tree view for courses, and check some entries, an "Action" menu appears with a number of options (in this case, "Export" and "Delete"). I'd like to add a new option and bind it to some backend logic to be executed on the selected elements.

I found some hints online (e.g: https://stackoverflow.com/questions/36285497/how-to-add-entry-to-more-menu-or-top-menu-to-add-action-on-multiple-selections), but it doesn't seem to be working on odoo11.

Is there a standard way to accomplish that?

EDIT:

For now I managed to insert a button like the following

<button name="mymethod" string="My Method" type="object" class="oe_highlight"/> 

and I binded it to a simple @api.multi method in the model:

    @api.multi
def mymethod(self):
print("TEST")
return True

This works (i.e. when the button is clicked i see the "TEST" string in the console), but still I need to understand how to bind the method to an option in the "Action" drop-down (not to a button).

I managed to do a window action linked to an option in the "Action" drop-down (If i'm not wrong this is accomplished by setting the key2 field as "client_action_multi"), but what I need is a server action, so, by analogy, I tried to define it as follows:

<record model="ir.actions.server" id="act_new_sub_menu_lol">
<field name="name">CANT MAKE THIS WORK</field>
<field name="model_id" ref="model_openacademy_course"></field>
<field name="src_model">openacademy.course</field>
<field name="key2">client_action_multi</field>
<field name="view_mode">tree</field>
<field name="target">new</field>
<field name="view_type">tree</field>
</record>

But no option appears in the drop-down.


Thank you in advance for any help.

Avatar
Discard
Best Answer

<act_window id="action_set_invoice_done"

            name="Your menu name"

            src_model="menu will display on this model"

            res_model="wizard model"

            view_type="form" view_mode="form"

            key2="client_action_multi" target="new"

/>


Example: Under Invoice tree i added set done menu

<act_window id="action_set_invoice_done"

            name="Set Done"

            src_model="account.invoice"

            res_model="set.invoice.done"

            view_type="form" view_mode="form"

            key2="client_action_multi" target="new"

            groups="account.group_account_manager"/>

Avatar
Discard
Author

Thank you for your answer! I guess, then, that i have to make a wizard/popup appear when the option is clicked? I was looking for a way to directly call a server-side method, but I think I can cope with that anyway. Thank you again.

Related Posts Replies Views Activity
2
Mar 19
2251
1
Oct 18
7398
1
Dec 22
4326
0
Dec 24
7
0
Nov 24
6