A professional Odoo Sequence Setup is more than just an administrative task; it’s a critical part of your brand’s communication and operational efficiency. When a customer receives a quote, the document number is one of the first things they see. Does S00001 for a quote, which then stays S00001 as an order, feel a bit… generic? It can lead to confusion for both your team and your clients. What if you could have a distinct, professional numbering system that automatically differentiates between quotations and confirmed sales orders?
Imagine this workflow: a customer receives a document labeled Q-2024-0012. It’s clearly a quotation. When they approve it, the document seamlessly transforms into a confirmed sales order with a new, distinct number: SO-2024-0098. This is not just a fantasy; it’s a powerful capability you can unlock in Odoo with the right configuration.
In this ultimate guide, we will walk you through the entire process, step-by-step. We’ll show you how to configure a dynamic Odoo Sequence Setup that automatically assigns different sequences to your quotes and sales orders. Say goodbye to ambiguity and hello to a streamlined, professional, and automated document flow.
Why a Custom Odoo Sequence Setup Matters
Before we dive into the “how,” let’s quickly cover the “why.” Investing a few minutes in a proper document numbering system provides significant benefits:
- Enhanced Professionalism: Distinct numbering for quotes and orders signals a well-organized and professional operation to your clients.
- Improved Clarity: It eliminates any confusion about whether a document is a preliminary quote or a binding order.
- Simplified Internal Tracking: Your sales, accounting, and warehouse teams can instantly identify the status and nature of a document just by looking at its number.
- Automation Power: Once set up, the system runs on autopilot, saving you time and preventing manual errors.
The Goal: Dynamic Sequences for Quotes and Orders
Our objective is to configure Odoo to perform the following:
- When a new quotation is created, it will be assigned a sequence with a “Q” prefix (e.g.,
Q0001). - When that quotation is confirmed and becomes a sales order, Odoo will automatically assign it a brand-new sequence with an “SO” prefix (e.g.,
SO0023).
Let’s get started with your new Odoo Sequence Setup.
Step 1: Activate Developer Mode
To access the technical settings we need, you must first activate developer mode.
- Navigate to Settings.
- Scroll to the bottom and click “Activate the developer mode.”
You’ll know it’s active when you see a bug icon in the top right corner.
Step 2: Create Your Custom Sequences
The foundation of our setup is creating two distinct sequences. One for quotes and one for confirmed orders.
- Navigate to Settings > Technical > Sequences & Identifiers > Sequences.
A. Create the Quotation Sequence
- Click Create.
- Fill in the form with the following details:
- Name:
Quotation Sequence - Implementation: Standard
- Prefix:
Q - Sequence Size:
5(This means the number will be padded with zeros to be 5 digits long, e.g.,00001). - Step:
1 - Code:
sale.quotation(This is crucial! The code is what we will use to call this sequence later. Make it simple and memorable.)
- Name:
- Click Save. (Note: Placeholder for an illustrative image showing the sequence form)
B. Create the Sales Order Sequence
- Now, let’s create the sequence for confirmed orders. Click Create again.
- Fill in the form:
- Name:
Confirmed Sales Order Sequence - Implementation: Standard
- Prefix:
SO - Sequence Size:
5 - Step:
1 - Code:
sale.order.confirmed(Again, a unique and clear code is essential.)
- Name:
- Click Save.
You now have two dedicated sequences ready to be used. The default Odoo sequence for sales will now be used for quotations. To make this explicit, you can find the original Sale Order sequence and change its prefix to Q- and ensure its code is sale.quotation.
Step 3: Configure the Default Sales Sequence
To ensure all new quotations automatically use our new ‘Q’ sequence, we need to tell Odoo to use it by default.
- In the Sales app, go to Configuration > Settings.
- Ensure the
Sale Ordersequence is set to the one you’ve designated for quotations (Quotation Sequencewith the codesale.quotation). For now, we only need to set this one. The other sequence will be triggered by our automation.
Step 4: The Core Logic – Build the Automated Action
This is where the magic happens. We will create an automated action that triggers when a quotation’s status changes to “Sales Order,” and it will fetch a new number from our “Confirmed Sales Order Sequence.”
- Navigate to Settings > Technical > Automation > Automated Actions.
- Click Create.
Fill out the automated action form as follows:
- Action Name:
Change Sequence on SO Confirmation - Model:
Sale Order (sale.order) - Trigger:
On Update - Apply on: This is a filter to ensure the action only runs on the specific records we care about. We want it to run when a document that was a quotation becomes a sales order. Click Add Filter and set the domain to:
[["state", "=", "sale"]]
This ensures the action only runs when the record’s state is set tosale(Sales Order). (Note: Placeholder for an illustrative image showing the automated action form) - Now, switch to the Actions tab.
- Action To Do: Select
Execute Python Code.
A Python code editor will appear. This is the engine of our custom Odoo Sequence Setup.
Step 5: Implement and Understand the Python Code
Copy and paste the following Python code into the editor. This script is responsible for grabbing a new number from our confirmed order sequence and writing it to the sales order.
# The unique code for our "Confirmed Sales Order Sequence"
sequence_code = 'sale.order.confirmed'
# Check if the record's name still uses the quotation prefix.
# This prevents the action from running again on an already confirmed order.
if record.name.startswith('Q'):
# Fetch the next number from our custom sequence by its code
new_name = env['ir.sequence'].next_by_code(sequence_code)
# If a new sequence number was successfully generated, write it to the record
if new_name:
record.write({'name': new_name})
Let’s break down this script so you understand exactly what it’s doing:
sequence_code = 'sale.order.confirmed': We define the uniqueCodeof the sequence we want to use. This must match the code you created in Step 2B.if record.name.startswith('Q'):: This is a safety check. It ensures the code only runs if the order’s current number starts with our quotation prefix (Q). This prevents it from accidentally re-numbering an already confirmed order if it’s edited later.env['ir.sequence'].next_by_code(sequence_code): This is the most important line.env['ir.sequence']accesses the Odoo model responsible for handling all sequences..next_by_code(...)is a powerful Odoo method that finds a sequence by its code and returns the next available number. For more technical details, you can explore the official Odoo documentation on the ORM API.
record.write({'name': new_name}): If a new number was successfully generated, this line updates thenamefield of the current sales order (record) with the new sequence number (new_name).
Click Save, and your advanced Odoo Sequence Setup is complete!
Putting It to the Test
Now for the rewarding part. Let’s verify our work:
- Go to the Sales app and create a new quotation. Save it. You should see its number starting with
Q(e.g.,Q00001). - Now, click the Confirm button.
- Voilà! The page will refresh, and the document number will instantly change to your new sales order sequence, starting with
SO(e.g.,SO00001).
You have successfully created a clear, professional, and fully automated document numbering system. For more ways to streamline your business, you might be interested in our guide to Advanced Odoo Automation Rules.
Conclusion
A thoughtful Odoo Sequence Setup is a simple yet powerful way to elevate your business operations. By moving away from a one-size-fits-all numbering system, you introduce a level of professionalism and clarity that benefits everyone, from your customers to your internal teams.
With just a few custom sequences and a small but mighty automated action, you have taken control of your document flow, reduced ambiguity, and made your Odoo system work smarter, not harder. Now that you’ve seen how easy it is, what other processes in your business could you streamline? To learn more about what’s possible, check out what’s new in Odoo 18.
Discover more from teguhteja.id
Subscribe to get the latest posts sent to your email.

