Enable Dark Mode!
how-to-add-a-button-inside-action-menu-in-odoo-19.jpg
By: Swaraj R

How to Add a Button Inside Action Menu in Odoo 19

Technical Odoo 19 Odoo Enterprises Odoo Community

In Odoo, sometimes you want to perform bulk actions on multiple records without adding extra buttons to the form or tree views. The Action Menu is the perfect place to put such operations. This feature uses Server Actions, which allow you to trigger Python code, open reports, send emails, or even create or update records — all directly from the Action dropdown.

Step-by-Step Implementation

We’ll create a new button in the Action Menu to confirm multiple sales orders at once.

XML: Create the Server Action

<!-- my_module/data/sale_order_actions.xml -->
<odoo>
    <record id="action_confirm_sale_orders" model="ir.actions.server">
        <field name="name">Confirm Orders</field>
        <field name="state">code</field>
        <field name="model_id" ref="sale.model_sale_order"/>
        <field name="group_ids" eval="[Command.link(ref('base.group_system'))]"/>
        <field name="binding_model_id" ref="sale.model_sale_order"/>
        <field name="binding_view_types">list,kanban</field>
        <field name="code">
            for record in records:
                if record.state == 'draft':
                    record.action_confirm()
        </field>
    </record>
</odoo>

Python (Optional): Add Custom Business Logic

# my_module/models/sale_order.py

# -*- coding: utf-8 -*-
from odoo import models
class SaleOrder(models.Model):
    _inherit = 'sale.order'
    def action_bulk_confirm(self):
        for order in self:
            if order.state == 'draft':
                order.action_confirm()

And then in the XML, instead of writing the loop, you can simply call:

<field name="code">
    records.action_bulk_confirm()
</field>

Manifest: Include the XML in Your Module

# my_module/__manifest__.py

{
    'name': 'Custom Sale Order Actions',
    'version': '19.0.1.0.0',
    'depends': ['sale'],
    'data': [
        'data/sale_order_actions.xml',
    ],
    'installable': True,
    'application': False,
}

How It Works

  1. The binding_model_id links the server action to the sale.order model.
  2. The binding_view_types defines where the action appears (list, kanban, etc.).
  3. The code field contains the Python logic executed when the action is triggered.

Once installed, if you go to settings > Technical > Actions > Server Actions you can see the created record like below,

How to Add a Button Inside Action Menu in Odoo 19-cybrosys

Go to the Sales Orders list view, select multiple records, open the Action dropdown, and you’ll see the new Confirm Orders action. Clicking it will confirm all selected draft sales orders.

How to Add a Button Inside Action Menu in Odoo 19-cybrosys

In this blog, you’ll learn how to create a button inside the Action Menu in Odoo 19, understand how the <field name="state"> works, and implement it with real examples.

Understanding <field name="state"> in Server Actions

The <field name="state"> field defines what type of action will be performed when the server action is executed. Here are the commonly used values:

StateDescription
codeExecutes custom Python code on the selected records.
object_createCreates new records in the specified model.
object_writeUpdates specific fields on the selected records.
object_copyDuplicates (copies) the selected records.
mail_postPosts a message in the chatter of the selected records.
followersAdds followers on the selected records.
remove_followersRemoves followers from the selected records.
next_activityCreates a scheduled activity (to-do) on the selected records.
sms

Send an SMS message to the selected records.

multiExecutes multiple actions defined in sequence.
webhookSends data to an external URL (webhook) for integration with external systems.

Most of the time, for custom development, the code state is used because it allows you to write Python logic directly in the server action.

Conclusion

Adding a button to the Action Menu in Odoo 19 is a clean and user-friendly way to perform bulk operations or trigger custom logic. By understanding how the <field name="state"> works, you can create powerful server actions — from executing Python code to printing reports, sending emails, or even opening different views. This approach keeps your interface uncluttered while giving users quick access to important actions.

To read more about How to Add a Button Inside the Action Menu in Odoo 18, refer to our blog How to Add a Button Inside the Action Menu in Odoo 18.


If you need any assistance in odoo, we are online, please chat with us.



0
Comments



Leave a comment



whatsapp_icon
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message