Auto-Remove Cancelled Pickings in Odoo Batch Transfers

Ways to Handle Cancelled Pickings in Odoo

Batch Transfers in Odoo make warehouse operations faster by grouping deliveries and processing them together. However, a common issue arises when a picking is cancelled, it often still remains inside the Batch Transfer list, leading to:

  • Confusion for warehouse staff
  • Incorrect processing of cancelled pickings
  • Extra manual cleanup work

In this blog, we’ll show you two ways to remove cancelled pickings from Batch Transfers in Odoo automatically:

  • Using a Python customisation (for developers)
  • Using an Automated Action (no code needed)

Method 1: Python Customisation

For development-focused projects, you can extend the stock.picking model to unlink pickings from batch transfers when cancelled automatically.

Example Code
# -*- coding: utf-8 -*-
from odoo import models
class StockPicking(models.Model):
    _inherit = 'stock.picking'
    def action_cancel(self):
        """
        Inherit cancel action to remove
        cancelled pickings from batch transfers
        """
        res = super(StockPicking, self).action_cancel()
        for picking in self:
            if picking.batch_id:
                # unlink picking from batch transfer
                batch.write({'batch_id': False})
                # optional: log activity
                picking.message_post(
                    body=f"Picking {picking.name} removed 
                         from Batch {batch.name} after cancellation."
                )
        return res
How It Works
  1. Inherit action_cancel() → Runs when a picking is cancelled.
  2. Check for batch_id → If the picking belongs to a batch, it’s identified.
  3. Unlink picking from batch → Set Batch record blank.
  4. Log activity (optional) → Adds a note in chatter for transparency.

Method 2: Automated Action

(No Code Required)

If you prefer a configuration-only approach, Odoo’s Automated Actions can handle this automatically.

Steps to Configure
1. Navigate to:

Settings → Technical → Automation → Automated Actions

2. Create a New Automated Action
  • Model: Transfer (stock.picking)
  • Trigger: State is set to → Cancelled
  • Apply On: Add domain → Status = Cancelled
  • Action To Do: Update Record → Set Batch Transfer field to blank
Odoo Automated Action configuration to remove cancelled pickings from Batch Transfers
Example Configuration

As shown in the screenshot:

  • Trigger: When a transfer’s state changes to Cancelled
  • Condition: Apply only if Status = Cancelled
  • Action: Update the Batch Transfer field to empty

This way, the cancelled picking is automatically unlinked from its batch.

Which Method Should You Use?

Automated Action (Simple, No Code)
  • Best for quick setups
  • Works well if you just need to clear the Batch Transfer field
Python Customisation (Flexible, Advanced)
  • Better for complex workflows
  • Allows chatter logging, extra validations, or other custom rules

Found this article useful?

Explore more development guides and solutions from our team.

Check out more posts
Sign in to leave a comment
Restoring Odoo Database from .sql / .dump File