Odoo 10 Workflows Partial Removal

Hieu Le


Since the release of Odoo 9, they have decided to remove workflows in Sales and Purchase modules. There was a discussion about it in Odoo Community Mailing List community@mail.odoo.com. Why did they do that? Fabien Pinckaers, Odoo Founder, said that the Sales module in Odoo 8 had a lot of issues:
- not possible to modify a sale order (open orders)
- no way to handle inter-company invoicing based on delivery/receptions (only one of the two invoices was generated)
- not possible to invoice kits based on deliveries
- too many different ways to invoice customers: based on sale order, based on sale order lines, based on support contracts, based on regular contracts, based on expenses, based on delivery orders, final invoice on timesheets, …
- those different invoice methods could not be mixed in a single sale order (sell physical products with a support contract on timesheets)
- some of these invoicing methods were very complex to configure: to invoice on timesheet, you had to: 1/ create a SO, 2/ create a contract, 3/ set a product on the employee form, 4/ set the analytic_user_function to know to role of the user, 5/ invoice from the contract ...
- contracts (based on analytic accounts) are a pain. They are complex to understand (support contracts vs regular contracts) and to manage on a regular basis. (e.g. How do you make a quotation for a new support contract?)

In short, Odoo did a huge source code refactoring of the sale.* and purchase.* modules while porting them to the new API. As the result, 5000 lines of code were removed, for more features supported, and no feature removed. Compared to version 8, all complex use cases work perfectly in version 9 as there is no strictly restriction with workflows.


Let us travel back in time to understand the concept of workflows in Odoo 8. You can visit Odoo Runbot and run an Odoo 8 instance to check. Login as Administrator, go to menu Settings > Technical > Workflows, there are workflows for Sales Order, Purchase Order, Purchase Requisition, Payment Order, Account Invoice, HR Payslip, MRP …

Workflows menu in Odoo 8


Sales Order workflow in Odoo 8


Sales Order workflow diagram in Odoo 8


To help you to understand it, I am going to explain basic definitions of Workflow, Activity, Transition, Instance, Work Item.
Workflow is the series of activities that are necessary to complete a task. Each step in a workflow has a specific step before it and a specific step after it, with the exception of the first step. The purpose is to organize information passing through business processes in a company. Odoo had a friendly view of a workflow that helped to map business processes to Odoo.
Activity (or Workflow Node) is related to the State of the document. For example, in Sales Order workflow diagram, we have activities in oval shape such as draft, wait_invoice, wait_ship, cancel, done … The activities shaded in gray are the ones begin or end the workflow (Draft, Cancel, Done ...)
Transition is the arrow in the workflow diagram. Transitions between Activities link the steps in a workflow.
Instance (menu Settings > Technical > Workflows > Instances) is when a process takes place, the system record its workflow status.
Work Items (menu Settings > Technical > Workflows > Workitems) are to record the history of each steps in a workflow instance.
Read more: Odoo Workflows.

Let us go deeper into Sales Order workflow.

The states (or stages) on the right are changed when the buttons on the left are clicked respectively. Except the button Print to print out the Sales Order report.


- Button Send by Email will trigger signal quotation_sent and proceed to the activity sent.
- Button Confirm Sale will trigger signal order_confirm and proceed to the activity router.
- Button Cancel Quotation will proceed to the activity cancel.

Double click on the activity sent to discover it. 

Sales Order workflow - sent activity


The Python Action can be a set of functions being called one by one in an order. For example, I am viewing the open activity in the Invoice workflow. Firstly, the Invoice Date will be assigned, then Accounting Entries and Accounting Items will be created, then the Invoice Sequence Number will be generated, and finally the Invoice state will be updated to Validate.

Invoice workflow - open activity


Then a Sales Order reaches the state sent, the Python function will be called to update its state to ‘sent’. If ‘Flow Start’ is ticked, it indicates the starting activity, while ‘Flow Stop’ is the ending one (in gray oval shape). A workflow has only one start, but it can has many stops.


Tab Transitions shows the previous and next activities which the current one links to. From the draft activity, the button Send by Email (technical name in source code is quotation_sent) is the signal  triggering the transition to the sent activity. Likewise, from the sent activity, the signal order_confirm transits the flow to the router activity, and with the signal cancel, it goes to the activity cancel.


Open the Transition form view, one thing to note here is the field Group Required, I selected Sales / Manager group which means only users in  that group are allowed to trigger the signal order_confirm.
In source code, workflows are defined by using XML. Examining the Sales module, you will see the file sale_workflow.xml. In this post, I would like to bring out the most important things for people without technical background to understand, I will not go into lower level of source code where we can define buttons and Python functions, those are for developers.




Odoo R&D Team shared a bit about their work in the recent months in this topic. Regarding the workflow, they said ‘we are finalizing the removal of the workflows in the main addons. This does NOT mean that we are removing the workflow engine. It will still be available in the next release for the community modules.’ Indeed, at the moment, some are still available in Odoo 10. It will be release in Oct 2016. Until then, there might be more changes with the workflows. I compare the number of workflows between Odoo 8 (18 items) and Odoo 10 Community (10 items). Odoo 10 Enterprise also has 10 workflows, the same as in the Community version.

18 Workflows in Odoo 8


10 Workflows in Odoo 10 Enterprise


The questions is ‘Without workflows how does Odoo handle the process?’ Let us look into the Sales module in Odoo 10 Community version.
The buttons and states are still there. 


After I confirm the Sales Quotation, the button Lock (in Odoo 9, it was the button Done) appears. If the Sales Order is locked, you cannot modify it anymore, however, you will still be able to invoice and deliver. Compared to Odoo 8,  Done means ‘delivered and invoiced’. And once you confirm a Sales Quotation, you cannot modify it. Regarding Invoice creation, you can do only one time, one Sales Orders in Odoo 8 has only one Invoice. Now we have the flexibility in Odoo 10 without workflows, no more problem of merge, partial invoices, control of quantities if invoiced or received in several steps, ...


If I want to create several partial Invoices for one Sales Order, I can do that thanks to the flexibility and the new field Invoiced quantity on Sales Order Lines. Likewise, field Delivered shows me the delivered quantity in case of partial delivery.  


Source code is also different. Let us look into the function handling button Confirm.
In Odoo 8, it calls workflow engine to process.


In Odoo 10, no more workflow engine is used.


This also means that there is no Workflow Instances and Workitems created for Sales Order process. In my opinion, I like this because I do not have to care about those data, the speed is faster, I can save some spaces in database. Another point is about the migration, I think it will save some time on workflows, instances, and work items.


By the way, there are also changes in Purchase Orders with a similar concept (no workflow, added quantity delivered, quantity invoiced). In Odoo 8, you had three methods to generate draft invoices: based on Purchase Order, based on Purchase Order Lines, based on Receptions. It is much easier in version 9 or 10, there are no methods. Odoo does not  pre-generate draft invoices anymore, but you can select Purchase Orders when you create a Vendor Bill, it will populate all invoice lines automatically based on what can be invoiced (received products or services).


OpenUpgrade is an open source migration framework from OCA (Odoo Community Association). If you need to migrate your Odoo to newer version, you will need it. It provides a library openupgradelib for manipulation and migration of the database. It is more like database migration. OpenUpgrade supports native Odoo modules. For your custom modules, you might need to check and migrate the source code first, as since Odoo 10, it does not support Odoo API  version 7 anymore. Then you need to analyse your modules, if needed, adjust or write more migration scripts to support them. Read more: OpenUpgrade documentation.
OpenUpgrade = Odoo modules + migration scripts in each module
At the moment, it partially supports Odoo 9 Community version. The current progress is updated at Migration scripts for v9 #400. There are still lots of modules in need of migration scripts.
Taking a look at module Sales in OpenUpgrade branch 9.0 to see what we have.

Folder migrations stores the necessary scripts.
Openupgrade_analysis.txt: generated from the analysis phase.
Openupgrade_analysis_work.txt: a copy of Openupgrade_analysis.txt, plus your comments and analysis.
Pre-migration.py: run before a regular module upgrade, for some reasons, you might need to make changes in the database such as renaming tables, columns in database, update data, or clone columns for backup purpose.
Post-migration.py: run after a regular module upgrade, new data could be generated by the module, then you might need to do more adjustments in database.
In the end, the final purpose is the consistency between python models in source code, data structure and data in database. We have a current database using Odoo version 8 for example, we use OpenUpgrade to manipulate it so that it can be compatible and usable with Odoo version 9 or 10.
Let us get back to the Sales workflows. Because they were removed, so in the migration script, we have nothing to do. New Sales Orders in future will not use workflows. For current Sales Order in database, just let the existing workflows data generated before as it is, for further reference.


What I write here sounds simple. But the complexity of Odoo migration is very very high because of other relevant factors such as database constraints, the relation betweens Odoo modules. Normally, Sales module does not stand alone, but it interacts with Invoice, CRM, etc ... as it is an ERP system. Once you start it, more problems will come for sure. You might need to repeat it many times before achieving the desirable result. One thing to note here is that OpenUpgrade is incremental which means if you want to migrate from Odoo 8 to Odoo 10, you need to do from 8 to 9, then 9 to 10 step by step. And that would be a heavy work.


Although there are some benefits of having workflows such as: it is a visualization of business process, it auto triggers of actions if some conditions are met, it helps easily manage access rights on steps ... I think I am happy with the workflows removal in Odoo 9 and 10. For me, it is more flexible in handling the Sales Order and other related documents like Invoices, Shipment. No more worries about the connection and data consistency between the original documents (Sales, Purchase ...) and their status in Workflow Instances, Work Items. And finally, it is much easier for the migration I think, as we have less work to do, less data to migrate, followed by less problems we might face.