-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
689 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
============================================== | ||
Sale Order Blanket Order Stock Prebook Release | ||
============================================== | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:3f68147daefc9ef868a5b6ba780abc44482618234844943c4d62564d0ba1351d | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |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_stock_prebook_release | ||
: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_stock_prebook_release | ||
: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 is a glue module between | ||
sale_order_blanket_order_stock_prebook and | ||
stock_available_to_promise_release | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Use Cases / Context | ||
=================== | ||
|
||
When a call-off order is confirmed for a product, the priority date used | ||
to compute the available quantity available at promised date must be the | ||
start date of the blanket order. | ||
|
||
This is required to ensure that the principle of first-come, | ||
first-served is respected. In the case of a product part of a blanket | ||
order the date to consider must be the start date of the blanket order | ||
and not the date of the call-off order. | ||
|
||
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_stock_prebook_release%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 | ||
|
||
Contributors | ||
------------ | ||
|
||
- Laurent Mignon laurent.mignon@acsone.eu (https://www.acsone.eu) | ||
|
||
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_stock_prebook_release>`_ 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 post_init_hook |
18 changes: 18 additions & 0 deletions
18
sale_order_blanket_order_stock_prebook_release/__manifest__.py
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,18 @@ | ||
# Copyright 2025 ACSONE SA/NV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Sale Order Blanket Order Stock Prebook Release", | ||
"summary": """Ensure that the date priotity when releasing""" | ||
""" qty is the start date of the blanker order""", | ||
"version": "16.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "ACSONE SA/NV,Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/sale-workflow", | ||
"depends": [ | ||
"sale_order_blanket_order_stock_prebook", | ||
"stock_available_to_promise_release", | ||
], | ||
"auto_install": True, | ||
"post_init_hook": "post_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,33 @@ | ||
# Copyright 2025 ACSONE SA/NV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
import logging | ||
|
||
from odoo import SUPERUSER_ID, api | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
def post_init_hook(cr, registry): | ||
"""Create `account.payment.method` records | ||
for the installed payment providers. | ||
""" | ||
_logger.info( | ||
"Executing post init hook for module " | ||
"sale_order_blanket_order_stock_prebook_release" | ||
) | ||
env = api.Environment(cr, SUPERUSER_ID, {}) | ||
blanket_orders = env["sale.order"].search( | ||
[("order_type", "=", "blanket"), ("state", "in", ["sale", "done"])] | ||
) | ||
|
||
_logger.info( | ||
f"Found {len(blanket_orders)} blanket orders to compute the move date priority" | ||
) | ||
blanket_orders._compute_blanket_move_date_priority() | ||
|
||
_logger.info("Setting the move date priority for the blanket orders move lines") | ||
for move_id in blanket_orders.order_line.move_ids: | ||
if move_id.state not in ("done", "cancel", "assigned"): | ||
move_id.date_priority = ( | ||
move_id.sale_line_id.order_id.blanket_move_date_priority | ||
) |
2 changes: 2 additions & 0 deletions
2
sale_order_blanket_order_stock_prebook_release/models/__init__.py
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 sale_order_line | ||
from . import sale_order |
61 changes: 61 additions & 0 deletions
61
sale_order_blanket_order_stock_prebook_release/models/sale_order.py
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,61 @@ | ||
# Copyright 2025 ACSONE SA/NV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
from collections import defaultdict | ||
from datetime import timedelta | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class SaleOrder(models.Model): | ||
|
||
_inherit = "sale.order" | ||
|
||
blanket_move_date_priority = fields.Datetime( | ||
string="Move Date Priority", | ||
help="Date priority for the moves of the order.", | ||
) | ||
|
||
def action_confirm(self): | ||
self._compute_blanket_move_date_priority() | ||
return super().action_confirm() | ||
|
||
def _compute_blanket_move_date_priority(self): | ||
""" | ||
Compute the move date priority for the blanket orders. | ||
The move date priority for blanket orders is the validity start date of | ||
the blanket order incremented by the position of the order according to | ||
the confirmation date by blanket_validity_start_date. | ||
This method is called at the start of the confirmation process. | ||
""" | ||
blankets = self.filtered(lambda o: o.order_type == "blanket") | ||
# we need to query the count of confirmed blanket orders for each | ||
# blanket_validity_start_date | ||
if not blankets: | ||
return | ||
domain = [ | ||
( | ||
"blanket_validity_start_date", | ||
"in", | ||
blankets.mapped("blanket_validity_start_date"), | ||
), | ||
("order_type", "=", "blanket"), | ||
("state", "in", ["sale", "done"]), | ||
] | ||
res = self.env["sale.order"].read_group( | ||
domain, | ||
["blanket_validity_start_date:group_count"], | ||
["blanket_validity_start_date"], | ||
) | ||
count_per_date = defaultdict(int) | ||
for data in res: | ||
count_per_date[data["blanket_validity_start_date"]] = data[ | ||
"blanket_validity_start_date_count" | ||
] | ||
for order in blankets.sorted("create_date"): | ||
start_date = order.blanket_validity_start_date | ||
order_position = count_per_date.get(start_date, 0) | ||
order.blanket_move_date_priority = start_date + timedelta( | ||
seconds=order_position | ||
) | ||
count_per_date[start_date] = order_position + 1 |
19 changes: 19 additions & 0 deletions
19
sale_order_blanket_order_stock_prebook_release/models/sale_order_line.py
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,19 @@ | ||
# Copyright 2025 ACSONE SA/NV | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import models | ||
|
||
|
||
class SaleOrderLine(models.Model): | ||
|
||
_inherit = "sale.order.line" | ||
|
||
def _prepare_procurement_values(self, group_id=False): | ||
values = super()._prepare_procurement_values(group_id) | ||
order = self.order_id | ||
if ( | ||
order.order_type == "blanket" | ||
and order.blanket_reservation_strategy == "at_confirm" | ||
): | ||
values["date_priority"] = order.blanket_move_date_priority | ||
return values |
4 changes: 4 additions & 0 deletions
4
sale_order_blanket_order_stock_prebook_release/readme/CONTEXT.md
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,4 @@ | ||
When a call-off order is confirmed for a product, the priority date used to compute the available quantity available at promised date must be the start date of the blanket order. | ||
|
||
This is required to ensure that the principle of first-come, first-served is respected. | ||
In the case of a product part of a blanket order the date to consider must be the start date of the blanket order and not the date of the call-off order. |
1 change: 1 addition & 0 deletions
1
sale_order_blanket_order_stock_prebook_release/readme/CONTRIBUTORS.md
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 @@ | ||
- Laurent Mignon <laurent.mignon@acsone.eu> (https://www.acsone.eu) |
3 changes: 3 additions & 0 deletions
3
sale_order_blanket_order_stock_prebook_release/readme/CREDITS.md
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,3 @@ | ||
The development of this module has been financially supported by: | ||
|
||
- ALCYON Belux |
1 change: 1 addition & 0 deletions
1
sale_order_blanket_order_stock_prebook_release/readme/DESCRIPTION.md
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 @@ | ||
This module is a glue module between sale_order_blanket_order_stock_prebook and stock_available_to_promise_release |
Binary file added
BIN
+9.23 KB
sale_order_blanket_order_stock_prebook_release/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.