How to Auto Send Invoices in Odoo Faster

Managing customer invoice emails manually can consume a significant amount of time, especially when handling a large number of invoices daily. Delays in sending invoices can also impact customer experience and accounting workflows.

In this blog, we will see how to automate invoice email sending in Odoo using Scheduled Actions (Cron Jobs) together with Automation Rules to trigger the process instantly when an invoice is posted.

Why Improve the Default Odoo Invoice Email Flow?

Odoo provides a built-in scheduled action called “Send Invoices Automatically”, which processes invoices in the background. However, this cron job runs periodically, which can cause delays between invoice posting and email delivery.

To improve this, we can trigger the process instantly when an invoice is posted using Automation Rules.

With the Automation Rule, we can populate the sending_data field automatically when the invoice status changes from Draft → Posted

Understanding Odoo Invoice Email Flow

When the Send & Print button is clicked manually:

  • Odoo fills the sending_data field
  • The scheduled action processes the invoice
  • Email is sent asynchronously

The cron is typically based on a domain like:

[
('sending_data', '!=', False),
('state', '=', 'posted'),
]

The cron usually processes invoices in batches (for example, 10 invoices per execution).

Solution Overview

To improve this flow, we will:

  • Create an Automation Rule
  • Execute Python code automatically
  • Queue invoices when they are posted
  • Trigger the cron immediately

Step 1: Create an Automation Rule in Odoo

Navigate to:

Settings → Technical → Automation → Automation Rules

Create a new automation rule for the Journal Entry model.

Field Value
Trigger On create and edit
When Updating Status
Before Update Domain Draft Invoice
Apply On Posted Invoice
Domain Configuration
Before Update Domain

[
('state', '=', 'draft'),
('move_type', 'in', ['out_invoice', 'out_refund']),
('sending_data', '=', False),
('commercial_partner_id.email', '!=', False),
]

Apply On Domain

[
('state', '=', 'posted'),
('move_type', 'in', ['out_invoice', 'out_refund']),
('sending_data', '=', False),
('commercial_partner_id.email', '!=', False),
]

Step 2: Add Execute Python Code Action

Choose: Action To Do → Execute Code

Add the following Python code:

python
# Queue invoice for the standard "Send invoices automatically" cron.
# This does NOT send immediately; it uses Odoo's built-in async pipeline.
cron = env.ref('account.ir_cron_account_move_send')
for move in records:
    # extra safety
    if move.state != 'posted' or move.sending_data:
        continue
    if move.move_type not in ('out_invoice', 'out_refund'):
        continue
    if not move.commercial_partner_id.email:
        continue
    move.write({
        'sending_data': {
            'author_user_id': env.user.id,
            'author_partner_id': env.user.partner_id.id,
        }
    })
# Trigger cron instantly
cron._trigger()

How This Works

1. Invoice Gets Posted

When an invoice moves from Draft → Posted, the automation rule is triggered.

2. Validation Checks Run

The script validates:

  • The invoice is posted
  • The invoice type is a customer invoice or a credit note
  • Customer email exists
  • The invoice is not already queued
3. Invoice is Queued for Sending

The script writes data into the sending_data field, which marks it for email processing.

4. Cron Execution is Triggered

Instead of waiting for the next scheduled run, _trigger() initiates the cron execution process immediately.

Important Notes

Preventing Duplicate Emails

The condition ('sending_data', '=', False) ensures invoices are not queued multiple times.

When to Use This Approach

This automation is especially useful for:

  • Businesses sending a high volume of invoices daily
  • Teams wanting instant invoice delivery after validation
  • Reducing the manual email sending workload
  • Improving operational efficiency in accounting workflows

Conclusion

By combining:

  • Automation Rules
  • Scheduled Actions
  • Python Server Actions

You can build a fully automated invoice email system in Odoo without heavy customisation of core modules.

This improves efficiency, reduces manual workload, and ensures customers receive invoices immediately after validation.

We work with Odoo every day.

Check out our blog for more guides and how-to articles about Odoo.

View more articles
in ERP
Sign in to leave a comment
How to Integrate WhatsApp with Odoo