-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
lmignon
wants to merge
40
commits into
OCA:16.0
Choose a base branch
from
acsone:16.0-add-sale-framework
base: 16.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 14 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
8fd7874
[DO NOT MERGE] tests dependency
lmignon 86ffed5
[ADD] sale_order_blanket_order, sale_order_blanket_order_stock_prebook
lmignon 47c45f0
[FIX] sale_order_blanket_order: Not compatible with sale_blanket_order
lmignon 6db4530
fixup! [ADD] sale_order_blanket_order, sale_order_blanket_order_stock…
lmignon 14b4b03
fixup! [ADD] sale_order_blanket_order, sale_order_blanket_order_stock…
lmignon fb48c28
fixup! [ADD] sale_order_blanket_order, sale_order_blanket_order_stock…
lmignon d374a76
fixup! [ADD] sale_order_blanket_order, sale_order_blanket_order_stock…
lmignon 3ef53b7
fixup! [ADD] sale_order_blanket_order, sale_order_blanket_order_stock…
lmignon b8b9003
fixup! [ADD] sale_order_blanket_order, sale_order_blanket_order_stock…
lmignon 7cfac20
fixup! [ADD] sale_order_blanket_order, sale_order_blanket_order_stock…
lmignon 1b1aa70
fixup! [ADD] sale_order_blanket_order, sale_order_blanket_order_stock…
lmignon 25a0b15
fixup! [ADD] sale_order_blanket_order, sale_order_blanket_order_stock…
lmignon d9d79df
fixup! [ADD] sale_order_blanket_order, sale_order_blanket_order_stock…
lmignon eba97ff
fixup! [ADD] sale_order_blanket_order, sale_order_blanket_order_stock…
lmignon 72860aa
Update sale_order_blanket_order/readme/CONTEXT.md
lmignon 1dea676
Update sale_order_blanket_order/readme/CONTEXT.md
lmignon fba53aa
Update sale_order_blanket_order/readme/USAGE.md
lmignon f94cc96
Update sale_order_blanket_order/readme/DESCRIPTION.md
lmignon 3c87cc8
Update sale_order_blanket_order/readme/CONTEXT.md
lmignon 280c547
Update sale_order_blanket_order/i18n/fr.po
lmignon d072f86
Update sale_order_blanket_order/i18n/fr.po
lmignon 7b285f3
Update sale_order_blanket_order/models/res_company.py
lmignon cd0e0a2
Update sale_order_blanket_order/models/res_config_settings.py
lmignon 39dc6ff
Update sale_order_blanket_order/models/sale_order_line.py
lmignon c3b7363
Update sale_order_blanket_order/readme/CONTEXT.md
lmignon f2170ff
Update sale_order_blanket_order/readme/CONTEXT.md
lmignon e86a85e
Update sale_order_blanket_order/readme/CONTEXT.md
lmignon 7eb5057
[FIXUP] translations
lmignon a0016e3
[FIXUP] don't use freezetime at class level to avoid bloking tests
lmignon 8cc6357
[FIXUP] little improvements
lmignon 2977606
[FIXUP] check constrains on confirm to ease creation process
lmignon d4ff6cb
[FIXUP] raise right exception
lmignon be10c8d
[FIXUP] Improves perf
lmignon a4bb856
[FIXUP] check line overlap only at confirmation
lmignon dff351c
[FIXUP] no taxes on call off lines
lmignon 8051695
[FIXUP] allows to change the reservation strategy while the blanket o…
lmignon fff6a65
[FIXUP] allows to change the eol strategy while the blanket order is …
lmignon 666fa5a
[FIXUP] allows to control cut-off auto create on the SO
lmignon fb44614
FIXUP translations
lmignon 62b6d5e
[FIXUP] allows to update the product_uom_qty into blanket order
lmignon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
======================== | ||
Sale Order Blanket Order | ||
======================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:d0b6a096d18178fbd15da557bf07466d1ff491c59a2b56a17781a6d020da21dd | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
|
||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fsale--workflow-lightgray.png?logo=github | ||
:target: https://github.com/OCA/sale-workflow/tree/16.0/sale_order_blanket_order | ||
:alt: OCA/sale-workflow | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/sale-workflow-16-0/sale-workflow-16-0-sale_order_blanket_order | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/sale-workflow&target_branch=16.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
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. By default, the stock is not reserved upon | ||
confirmation of the blanket order. This is achieved by using the OCA | ||
module | ||
`sale_manual_delivery <https://pypi.org/project/odoo-addon-sale-manual-delivery/>`__. | ||
As a result, the stock will be reserved only when a call-off order is | ||
created for the quantity to be delivered. | ||
|
||
In some cases, you may want to reserve stock upon confirmation of the | ||
blanket order. This can be achieved by using the OCA module | ||
`sale_order_blanket_order_stock_prebook <https://pypi.org/project/odoo-addon-sale-order-blanket-order-stock-prebook/>`__. | ||
This module extends the functionality of Sale Blanket Order to support | ||
the reservation of stock for future consumption by call-off orders. The | ||
reservation is done at the time of the blanket order confirmation for a | ||
consumption starting at the validity start date of the blanket order. | ||
This behavior can be configured on the blanket order. | ||
|
||
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. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Use Cases / 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 kinkds 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] <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, ...). | ||
|
||
Usage | ||
===== | ||
|
||
By default, the automatic creation of call-off orders from normal sale | ||
orders containing products part of a blanket order is disabled. To | ||
enable this feature, you need to go into the sales settings and enable | ||
the option "CCreate Call-Off from SO if possible". | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/sale-workflow/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/sale-workflow/issues/new?body=module:%20sale_order_blanket_order%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
------- | ||
|
||
* ACSONE SA/NV | ||
* BCIM | ||
|
||
Contributors | ||
------------ | ||
|
||
- Laurent Mignon\ [email protected] (https://www.acsone.eu) | ||
- Jacques-Etienne Baudoux (BCIM) [email protected] | ||
|
||
Other credits | ||
------------- | ||
|
||
The development of this module has been financially supported by: | ||
|
||
- ALCYON Belux | ||
|
||
Maintainers | ||
----------- | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
This module is part of the `OCA/sale-workflow <https://github.com/OCA/sale-workflow/tree/16.0/sale_order_blanket_order>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import models | ||
from .hooks import pre_init_hook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright 2024 ACSONE SA/NV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Sale Order Blanket Order", | ||
"summary": """Manage blanket order and call of ordr""", | ||
"version": "16.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "ACSONE SA/NV,BCIM,Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/sale-workflow", | ||
"depends": [ | ||
"sale_manual_delivery", | ||
], | ||
"excludes": ["sale_blanket_order"], | ||
"data": [ | ||
"views/sale_order.xml", | ||
"views/sale_order_line.xml", | ||
"views/res_config_settings.xml", | ||
"data/ir_cron.xml", | ||
], | ||
"demo": [], | ||
"pre_init_hook": "pre_init_hook", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2024 ACSONE SA/NV | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> | ||
<odoo noupdate="1"> | ||
<record | ||
forcecreate="True" | ||
id="ir_cron_sale_order_blanket_order_finalizer" | ||
model="ir.cron" | ||
> | ||
<field name="name">Finalize expired sale blanket orders</field> | ||
<field eval="True" name="active" /> | ||
<field name="model_id" ref="sale.model_sale_order" /> | ||
<field name="state">code</field> | ||
<field name="code">model._cron_manage_blanket_order_eol()</field> | ||
<field name="user_id" ref="base.user_root" /> | ||
<field name="interval_number">1</field> | ||
<field name="interval_type">days</field> | ||
<field name="numbercall">-1</field> | ||
<field name="doall" eval="False" /> | ||
<field | ||
name="nextcall" | ||
eval="(DateTime.now() + timedelta(days=1)).strftime('%Y-%m-%d 01:00:00')" | ||
/> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import logging | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
def pre_init_hook(cr): | ||
_logger.info("Create column order_type in sale_order with default value 'order'") | ||
cr.execute( | ||
"ALTER TABLE sale_order ADD COLUMN order_type varchar(255) DEFAULT 'order'" | ||
) | ||
# drop the default value since it was only used to fill the column in existing records | ||
cr.execute("ALTER TABLE sale_order ALTER COLUMN order_type DROP DEFAULT") | ||
|
||
_logger.info( | ||
"Create column order_type in sale_order_line with default value 'order'" | ||
) | ||
cr.execute( | ||
"ALTER TABLE sale_order_line ADD COLUMN order_type varchar(255) DEFAULT 'order'" | ||
) | ||
# drop the default value since it was only used to fill the column in existing records | ||
cr.execute("ALTER TABLE sale_order_line ALTER COLUMN order_type DROP DEFAULT") | ||
|
||
_logger.info( | ||
"Create columns for blanket order in sale_order and " | ||
"sale_order_line to avoid computing the field for all records at module install" | ||
) | ||
# avoid computing the field for all records at module install | ||
cr.execute( | ||
"ALTER TABLE sale_order_line ADD COLUMN call_off_remaining_qty double precision" | ||
) | ||
cr.execute( | ||
"ALTER TABLE sale_order_line ADD COLUMN blanket_validity_start_date date" | ||
) | ||
cr.execute("ALTER TABLE sale_order_line ADD COLUMN blanket_validity_end_date date") | ||
cr.execute("ALTER TABLE sale_order_line ADD COLUMN blanket_order_id integer") | ||
cr.execute( | ||
"ALTER TABLE sale_order ADD COLUMN blanket_reservation_strategy varchar(255)" | ||
) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)