Community mailing list archives


Sale and purchase workflow

Fabien Pinckaers (fp)
- 09/16/2015 01:46:44


A lot of people are asking more information about the changes in sale and purchase apps in Odoo 9, mostly the removal of the workflow.

In short, we did a huge cleanup of the sale.* and purchase.* modules while porting them to the new API. The result in 5000 lines of code removed, for more features supported, and no feature removed.


The v8 sale module 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 incoice 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?)


Complete rewrite the sale and purchase modules. We cleaned all the legacy code while porting everything to the new API. The net result is 5000 lines of python code removed. Less lines of code for more features is a good sign of something that is technically clean.

*What are the main changes?*

In addition to the quantity ordered field on sale order lines, you have three new fields: Qty Delivered, Qty Invoiced, Qty to Invoice. Qty delivered can be set manually (milestones of a project you invoice manually) or computed based on timesheets or delivery orders. The two others fields are always computed.

The product has a new field "Invoice Method": based on quantities ordered, based on quantities delivered (could be timesheets), based on time and material (reinvoice costs or expenses).

So, whatever the products/services, you always generate invoices based on sales order. All other methods disappeared, you can do everything from the sale order.

The meaning of "Done" in sales order in different. In v8, done means "delivered and invoiced". In v9, done means "you can not change the order anymore". Delivered and Invoiced are written on SO lines, not in the status.

We removed the workflow because it was a mess. For example, in version 8, the "state" field was used for the SO state (quotation --> sale order) as well as the invoice state and delivery state (done=delivered and invoiced). We splitted this in several computed fields:

  - State: Quotation --> Sent  --> Sale Order
  - Invoice State: Nothing to Invoice, To Invoice, Fully Invoiced, Upselling Opportunity
  - Delivered: quantities are set on SO lines

More over, as the user can edit the SO at any step, workflows were not useful anymore. It's also much faster now.

*What are the improvements?*

Compared to v8, all complex use cases work perfectly in v9:

- single point of invoicing: sale order --> super easy
- you can mix any kind of services and invoice everything at once from the sale order: pre-paid support contract, project invoiced on milestones, physical products, extra travel and expenses, etc.
- the system manages upselling opportunities (when delivered quantities > ordered quantities). Example: you sell a support contract of 25h, when you arrive at 30h on timesheets, the sale order switch to "Upselling Opportunity"
- inter-company rules with invoice for both the supplier and the customer, based on delivered quantities
- invoice kits, based on delivered quantities
- handle correctly unit of measures: sell a support contract by "Pack 40h", work by hours in your timesheets
- modify a confirmed SO: it will handle delivery and invoicing correctly
change prices on a confirmed SO: some lines are readonly or not based on what have already been invoiced
- more efficient management of deposits
- 3 ways to track services: manually (set milestones as done), timesheet on contract (the v8 method), timesheets on tasks
- correctly handle the right product when a user do timesheet (defined by the SO line): you can work as a senior developer or on a support contract --> no need for analytic_user_function anymore

What about purchases?

We also reviewed purchase orders with a similar concept (Qty delivered, Qty invoiced) In v8, you had three methods to generate draft invoices: based on PO, based on PO lines, based on receptions. It's much easier in version 9, there are 0 methods :)

We don't pre-generate draft invoices anymore, but you can select POs when you create a vendor bill: it will fill all invoice lines automatically based on what can be invoiced (received products or services).

No more problem of merge, partial invoices, control of quantities if received in several steps, ...

It's very difficult to explain such a huge change in just a small email.

So I hope this small email helps,

You can get more information in the documentation, some docs have been updated to the new process (check the sale tab):