Automate Sales Order Line Routing in Odoo

Why Automate Sales Order Line Routing?

by Dharmesh Patel

Managing sales orders in Odoo can become complex, especially when certain lines require specific routing based on conditions like urgency or product type. Manually handling this process can lead to delays and inconsistencies, particularly in high-volume environments or when dealing with urgent orders. Without automation, routing Sales Order lines can be time-consuming.

Automating this process ensures that orders are routed correctly and promptly, based on the conditions you define, such as order urgency or specific customer requirements. This article will guide you through setting up an automated action in Odoo that automatically routes Sales Order lines according to predefined criteria.

Setting Up Automated Actions

To set up an automated action in Odoo for routing Sales Order lines, you'll need to create a custom automated action that triggers based on certain conditions. Here’s a step-by-step guide to help you:

1. Navigate to Automated Actions
  • Go to Settings > Technical > Automation > Automated Actions.
  • Make sure you have developer mode enabled to access this section.
2. Create a New Automated Action
  • Click on Create to start a new automated action.
3. Define the Automated Action
  • Model: Select Sales Order Line as the model. This ensures the action is specific to Sales Order lines.
  • Trigger Condition: Choose when you want the action to be triggered. For example, you can select options like On Creation, On Update, or On Creation & Update. For example, select On Update if you want the action triggered when a Sales Order line is updated.
  • Trigger Fields: Specify the field that, when updated, will trigger the action. If you leave this empty, the action will be triggered by updates to any field. For instance, select Order Status (sale.order.line) to trigger the action based on status changes.
  • Condition: Add conditions for when the routing should occur (e.g. based on the product category or sales order state). For example, to route only orders tagged as "URGENT," you can apply the following domains:

Before Update Domain: This condition must be met before the record is updated.

["&","&",["order_id.tag_ids","=","URGENT"],["order_id.company_id","=",1],"|","|",["state","=","draft"],["state","=","sent"],["state","=",False]]

Apply on: This condition must be satisfied before executing the action rule.

["&","&",["state","=","sale"],["order_id.tag_ids","=","URGENT"],["order_id.company_id","=",1]]

4. Define the Action
  • ​Action To Do: Select Update the Record if you need to update specific fields based on the trigger conditions.
  • For instance, you might assign the route "ASH: Urgent transfers deliver in 3 steps" and the company Numla Ltd to the Sales Order Line if the sales order is tagged as "URGENT." (As shown in the screenshot below)
Define the action
5. Save and Test
  • Save the automated action and test it by creating or updating Sales Order lines. Verify that the routing works as expected based on the conditions you've set.
Automated action

Final Thoughts

Automating the routing of Sales Order lines in Odoo streamlines your workflow and ensures accuracy and consistency in order processing. You can significantly reduce the manual effort involved by setting up automated actions. Test the setup in your environment and explore other automation possibilities within Odoo to further optimise your operations.

Need more development tips?

Stay tuned to our blog.

Install Odoo 17 on Cloud Without Coding