Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][Add] sale_order_blanket_order #3436

Open
wants to merge 40 commits into
base: 16.0
Choose a base branch
from

Conversation

lmignon
Copy link
Contributor

@lmignon lmignon commented Nov 27, 2024

requires:

Context

When a company sells the same products to the same customers on a regular basis, it's a common business practice to create a sale framework that defines the terms and conditions of the sales.

If you need a way to define:

  • the terms and conditions of the sales,
  • the payment terms,
  • the delivery terms,

and also secure the quantities of the products to be delivered, the sale framework module is the right choice.

This module introduces 2 new kinds of sale orders:

  1. Sale Blanket Order: This is a sale order that defines the terms and conditions of the sales, the payment terms, the delivery terms, and secures the quantities of the products to be delivered. It is used to create sale orders that will be delivered in the future.

  2. Call of order: This is a sale order that is created to consume the quantities of the products secured in the sale blanket order.

Others modules can be used to provide the same kind of features. For example, the module (sale_blanket_order)[https://pypi.org/project/odoo-addon-sale-blanket-order] also defines the concept of sale blanket order. The main difference between the two modules is that the sale framework module extends the sale order model to add the sale blanket order and the call of order. This allows to keep the benefits of all the extensions made on the sale order model by other modules without having to adapt them to the sale blanket order model (discount, invoicing; inventory process, ...).

This module extends the functionality of Sale Order to support Blanket Order and Call of Order.

Blanket Order

A Blanket Order is a standard sales order with the following specific features:

  • Type: Classified as "Blanket Order".
  • Defined Duration: Includes a validity period (end date).
  • Payment Terms: Allows selection of preferred terms (e.g., 90 days end of month, upon delivery, etc.).
  • Invoicing Policy: Can be based on product settings or the order itself.
  • Stock Reservation: Allows advance reservation of sold quantities.
  • Handling Unfulfilled Quantities: Provides options for dealing with undelivered quantities upon order expiration.
  • Prices are calculated based on existing rules since it is a standard sales order type.

The blanket order serves as the central element triggering stock management and invoicing mechanisms.

Stock Management

Delivered quantities are tracked on the sales order lines as with regular sales orders.
The goods are not delivered upon confirmation of the blanket order, but stock can be reserved for the customer using OCA modules:

  • sale_manual_delivery: Marks sales orders as "manual delivery," preventing stock reservation or delivery preparation.
  • sale_stock_prebook: Marks sales orders as "to reserve," triggering stock reservation but blocking delivery preparation for such cases.

Invoicing

Standard invoicing policies apply (e.g., invoice on order or on delivery). Payment terms are configurable per order. Prepayment can be enforced by configuring the invoicing policy at the order level using the OCA module (sale_invoice_policy)[https://pypi.org/project/odoo-addon-sale-invoice-policy/].

Consumption Management

A wizard will be available on the blanket order to initiate a delivery. It allows users to select products and quantities for delivery. This action creates a Call-off Order linked to the blanket order.

Call-off Order

A Call-off Order is a standard sales order with these specific characteristics:

  • Type: Classified as "Call-off Order".
  • Linked to Blanket Order: Only includes products from the blanket order.
  • Delivery Release: Enables the release of reserved stock for delivery.
  • No Invoicing or Stock Management: These are handled via the linked blanket order.

Stock Management

No delivery is generated directly from the call-off order.

It triggers:

  • Release of the reserved quantity in the blanket order.
  • Adjustment of stock reservations for the remaining quantities.

Standard Sales Orders

To support existing workflows (e.g., e-commerce), call-off orders can be generated transparently from standard sales orders based on product and availability:

Entire orders may be converted into call-off orders if all products are linked to a blanket order.
Mixed orders split call-off items into a new call-off order, with both confirmed within the available quantities of the blanket order.

Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also sale_blanket_order in OCA.

"website": "https://github.com/OCA/sale-workflow",
"depends": [
"sale_manual_delivery",
"sale_stock_prebook",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These dependencies seem too much for a "framework".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably not the best name. I have no other idea as the name “sale_blanket_order” is already in use.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but it's not only a question of the name, but to require such dependencies, that I think they should be extension modules: sale_framework_manual_delivery and sale_framework_stock_prebook. It also highlights that even using sale.order as base, it requires you some glue code for making it work. I would include also order on the name to be more specific. It's true that is not easy to name this. What about sale_order_multi_purpose?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename this module to sale_order_blanket_order as it allows to define the sale order type of an order as a blanket order.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also remove the dependency to stock from this module and make another one for the glue with stock

@lmignon
Copy link
Contributor Author

lmignon commented Nov 27, 2024

@rvalyi
Copy link
Member

rvalyi commented Nov 27, 2024

There's also sale_blanket_order in OCA.

..and even a "vault" module in server-auth I dare to say (désolé ; french only).

---->[]

@pedrobaeza
Copy link
Member

In my experience in the past, extending a base model to behave different, requires more code to contain the undesired side effects than to add such features. Anyway, as said, having such heavy dependencies for the base module is too much IMO.

@lmignon
Copy link
Contributor Author

lmignon commented Nov 27, 2024

In my experience in the past, extending a base model to behave different, requires more code to contain the undesired side effects than to add such features. Anyway, as said, having such heavy dependencies for the base module is too much IMO.

We analyzed the existing code and the Odoo code in depth with @jbaudoux and given the need to manage invoicing, stock reservation, etc. at the blanket order level, it seemed simpler to us to define new SO types. Otherwise, all the specific flows for price management, invoicing, etc. would have had to be duplicated for new models. I've tried to clearly present the constraints and objectives in the 'readme' files.

The module is not a base nor a simple module and may be split into several modules if possible. Work in progress

@pedrobaeza
Copy link
Member

pedrobaeza commented Nov 27, 2024

..and even a "vault" module in server-auth I dare to say (désolé ; french only).

I don't get the joke I'm afraid.


I don't insist more on the architecture, but a module with a generic name should be generic, not so specific of your project, including what prebook may be. And this repo is also very crowded to have even more deformations on standard objects. I wonder if this would be something to be on a vertical like wms.

@lmignon lmignon changed the title [16.0][Add] sale_framework [16.0][Add] sale_order_blanket_order Nov 29, 2024
@lmignon lmignon force-pushed the 16.0-add-sale-framework branch 9 times, most recently from f88bfcb to 9e0515b Compare December 4, 2024 09:32
@lmignon lmignon force-pushed the 16.0-add-sale-framework branch from 9e0515b to c7c5388 Compare December 4, 2024 09:48
Copy link

@youring youring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @lmignon thanks for the huge work. Just a minor suggestion for naming.
IMHO, order_type is too common to be used here to just distinguish whether a sales order is a normal, blanket or call-off, and note that there's already a module sale_order_type which specializes in managing various order types.
From a functional user perspective, I think a more specific field name here would give the user a better idea of what it represents, thus less headaches.

@lmignon lmignon force-pushed the 16.0-add-sale-framework branch from 9ed8373 to 76554e9 Compare December 4, 2024 15:41
@lmignon
Copy link
Contributor Author

lmignon commented Dec 4, 2024

Hi @lmignon thanks for the huge work. Just a minor suggestion for naming. IMHO, order_type is too common to be used here to just distinguish whether a sales order is a normal, blanket or call-off, and note that there's already a module sale_order_type which specializes in managing various order types. From a functional user perspective, I think a more specific field name here would give the user a better idea of what it represents, thus less headaches.

Thank you the review. @youring I'll think about your comment about the naming even if I don't have a better idea at the moment. Once our functional tests are completed, I'll mark this PR as ready for review.

@lmignon lmignon force-pushed the 16.0-add-sale-framework branch from 76554e9 to 61df468 Compare December 4, 2024 16:17
@lmignon lmignon force-pushed the 16.0-add-sale-framework branch from 61df468 to a8c9cdf Compare December 5, 2024 08:04
@lmignon lmignon force-pushed the 16.0-add-sale-framework branch from a8c9cdf to acec66a Compare December 5, 2024 08:40
@nilshamerlinck
Copy link
Contributor

you probably noticed it already as I see you isolated them, but fyi tests seem to get stuck there:

image

and because builds were triggered for each of the last commits, it created a bit of traffic jam in the ci queue for some moment 😅 (until Stéphane killed pending jobs)

@lmignon lmignon marked this pull request as ready for review December 9, 2024 14:11
"author": "ACSONE SA/NV,BCIM,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/sale-workflow",
"depends": [
"sale_manual_delivery",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lmignon The install of this addon does not work on large database.

See: #3476

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rousseldenis
It worked on my very large database.... (even if it was not fast and should be improved)

@lmignon lmignon force-pushed the 16.0-add-sale-framework branch from 1d75625 to a4bb856 Compare December 11, 2024 13:38
@lmignon lmignon force-pushed the 16.0-add-sale-framework branch from 42184c7 to 6a9d7ad Compare December 19, 2024 09:37
@lmignon lmignon force-pushed the 16.0-add-sale-framework branch from 6a9d7ad to 62b6d5e Compare December 19, 2024 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants