1
votes

Am working with Odoo 10 and I want two things:

  1. Insert a button in the menu specified in the picture.enter image description here

Then the button,

  1. Will execute some code that operates with the selected objects.

I would like to know how to insert the button and the best approach for point number 2.

1

1 Answers

3
votes

Following is the way to create a new menu in More menu.

1. Need to create new action for that menu.

<record model="ir.actions.act_window" id="action_id_1">
    <field name="name">action.name</field>
    <field name="view_id" ref="view_id_1"/>
    <field name="domain">[]</field>
    <field name="context">{}</field>
    <field name="res_model">Current Model</field>
    <field name="view_type">form</field>
    <field name="view_mode">form</field>
    <field name="target">new</field>
</record>

2. Binding events to action

The available type of events are following

  • client_print_multi (print from a list or form)
  • client_action_multi (action from a list or form)
  • client_action_relate (action from a list or form)
  • tree_but_open (action on the items of a tree)

You have to use the client_action_multi and define the action_id in value. See below example.

<record model="ir.values" id="ir_value_id">
    <field name="model_id" ref="module_name.model_<model_name>" />
    <field name="name">Create Delivery</field>
    <field name="key2">client_action_multi</field>
    <field name="value" eval="'ir.actions.act_window,' + str(ref('action_id_1'))" />
    <field name="key">action</field>
    <field name="model">model.name</field>
</record>

So, At the end you have new option under the more menu.